||In recent years, highly effective treatments for hepatitis C virus (HCV) have become available. However, high prices of new treatments call for a careful policy evaluation when considering economic constraints. Although the current medical advice is to administer the new therapies to all patients, economic and capacity constraints require an efficient allocation of these scarce resources. We use stochastic dynamic programming to determine the optimal policy for prescribing the new treatment based on the age and disease progression of the patient. We show that, in a simplified version of the model, new drugs should be administered to patients at a given level of fibrosis if they are within prespecified age limits; otherwise, a conservative approach of closely monitoring the evolution of the patient should be followed. We use a cohort of Spanish patients to study the optimal policy regarding costs and health indicators. For this purpose, we compare the performance of the optimal policy against a liberal policy of treating all sick patients. In this analysis, we achieve similar results in terms of the number of transplants, HCV-related deaths, and quality of adjusted life years, with a significant reduction in overall expenditure. Furthermore, the budget required during the first year of implementation when using the proposed methodology is only 12% of that when administering the treatment to all patients at once. Finally, we propose a method to prioritize patients when there is a shortage (surplus) in the annual budget constraint and, therefore, some recommended treatments must be postponed (added).