Taking into account the public health importance of the human papillomavirus (HPV) control in the future, it is mandatory to assess the effect of the vaccination campaigns on the control of HPV spread and the associated diseases using reliable mathematical models. We propose a computational random network model with the aim of studying the transmission dynamics of HPV infections. This model reflects the herd immunity effect in the heterosexual network more accurately than the classical models. We perform a sensitivity analysis of the sexual behavior changes consisting of increasing the number of men who have sex with men (MSM), increasing the frequency of the intercourses and increasing the number of sexual partners. We find that large changes in the sexual behavior, in some extent, only have minor effects on the decline of the HPV infections in women and men in the current vaccination campaign in Spain (vaccination of young girls with a coverage of 70%). Therefore, the current vaccination program in Spain is robust for the heterosexuals. However, we cannot say the same for MSM, where they do not benefit by the herd immunity effect of the vaccination of girls, and consequently, the circulation of the virus among them remains unchanged. A consequence of the present study is that the effect of other external factors that may affect the transmission dynamics of the HPV, for instance, the tourism or the immigration, does not influence the protection provided by the current Spanish vaccination program.