Relevance of the research is due to the low proportion of successful hydrochloric acid treatments of near-bottomhole zones of carbonate reservoirs in the Perm region caused by insufficiently careful design and implementation of measures to stimulate oil production. Within the framework of this article, the development of a program is presented, which is based on an algorithm that allows determining the volume and rate of injection for an acid composition into a productive formation corresponding to the maximum economic efficiency during hydrochloric acid treatment. Essence of the proposed algorithm is to find the greatest profit from measures to increase oil recovery, depending on the cost of its implementation and income from additionally produced oil. Operation of the algorithm is carried out on the principle of enumerating the values of the volume and rate of injection for the acid composition and their fixation when the maximum difference between income and costs, corresponding to the given technological parameters of injection, is reached. The methodology is based on Dupuis's investigations on the filtration of fluids in the formation and the results of the experiments by Duckord and Lenormand on the study of changes in the additional filtration resistance in the near-well zone of the formation when it is treated with an acid composition. When analyzing and including these investigations into the algorithm, it is noted that the developed technique takes into account a large number of factors, including the lithological and mineralogical composition of rocks, technological parameters of the injection of a working agent and its properties, well design, filtration properties of the formation, properties of well products. The article provides an algorithm that can be implemented without difficulty using any programming language, for example, Pascal. Selection of the optimal values for the volume and rate of injection is presented in this paper, using the example of a production well at the Chaikinskoye oil field, located within the Perm region. Introduction of the developed algorithm into the practice of petroleum engineering will allow competent and effective approach to the design of hydrochloric acid treatments in carbonate reservoirs without a significant investment of time and additional funds.