In the United Kingdom, human immunodeficiency virus (HIV) transmission among men who have sex with men (MSM) is not under control, despite readily available treatment, highlighting the need to design a cost-effective combination prevention package. MSM report significantly reduced transmission risk behavior following HIV diagnosis. To assess the effectiveness of HIV diagnosis in averting transmission during highly infectious primary HIV infection (PHI), we developed a stochastic individual-based model to calculate the number of HIV-transmission events expected to occur from a cohort of recently infected MSM with and those without the behavior changes reported after diagnosis. The model incorporates different types of sex acts, incorporates condom use, and distinguishes between regular and casual sex partners. The impact on transmission in the 3 months after infection depends on PHI duration and testing frequency. If PHI lasts for 3 months and testing is performed monthly, then behavior changes after diagnosis would have reduced estimated transmission events by 49%-52%, from 31-45 to 15-23 events; a shorter duration of PHI and/or a lower testing frequency reduces the number of infections averted. Diagnosing HIV during PHI can markedly reduce transmission by changing transmission-risk behavior. Because of the high infectivity but short duration of PHI, even short-term behavior change can significantly reduce transmission. Our quantification of the number of infections averted is an essential component of assessment of the cost-effectiveness of strategies to increase detection and diagnoses of PHI.