One of the cornerstones of the National Program for Control and Eradication of Bovine Brucellosis and Tuberculosis in Brazil is the voluntary accreditation of free herds. We developed a stochastic cost–benefit analysis model for two types of dairy herds (high yield Holstein‐Zebu crossbred females and lower productivity smaller scale herds) to identify the technical and economic constraints of this process. The initial prevalence of infected animals and the impact of the disease in the structure and performance of the herd were derived from secondary data. Information on the costs and benefits of herd sanitation were compiled into a cost–benefit model at the herd level. The last step consisted of a scenario simulation to evaluate the impact of alternative policies to the certification process. For each scenario, we calculate the probability over time of a Benefit–Cost Ratio greater than 1 and of an Internal Rate of Return above 1% (the discount rate used in the model). Results show that larger and more intensive dairy farms, and also herds affected by brucellosis compared with tuberculosis‐positive herds, are more likely to achieve financial gains from the certification investment. The compensation for culled animals is important in the initial phase of herd sanitation and the premium payment on milk would help farmers to achieve a return on the investment over time. The model can be adapted to different and dynamic production, epidemiological and economic settings.