This paper presents an optimal control strategy and cost-effectiveness analysis for a dynamic model of cystic echinococcosis. A novel, time-varying model of echinococcosis was developed by integrating current prevention and control measures with the impact of health education. The model’s basic reproduction number under constant control is calculated, and its global dynamic behavior is analyzed. Using optimal control theory, the optimal solution for the time-varying control model is derived. Model parameters were estimated based on actual data and control measures from Baiyin City, Gansu Province, China, and the resulting numerical fit proved satisfactory. Additionally, a numerical simulation of the optimal solution was performed for 24 proposed prevention and control measures, along with an analysis of cost-effectiveness. The results validated the effectiveness of Baiyin City’s measures and indicated that implementing an integrated program of health education and treatment enhances the efficacy of prevention and control strategies. Findings further suggest that while health education or treatment alone can reduce echinococcosis transmission, a combined approach is more efficient and cost-effective. Specifically, a comprehensive prevention and control program-including human health education, safe disposal of infected livestock carcasses, preventing dogs from consuming infected organs, dog deworming, sheep immunization, and human treatment-is identified as the most cost-effective and effective strategy. A sensitivity analysis of key strategy parameters was also conducted. This study provides valuable theoretical support for the economically viable and effective prevention and control of cystic echinococcosis.