Models of infectious disease dynamics suggest that treatment, vaccination, and isolation are required for the control of infectious diseases. Considering that vaccination is one of the most effective methods to control infectious diseases, it is often not possible to rapidly vaccinate all susceptible populations in the early stages of the spread of infectious diseases due to the limitation of the number of vaccines, insufficient medical personnel, or the slow progress of vaccination efforts. Our simulation analysis by building an SVIWRD model found that the degree of negative impact of infectious diseases shown when young and old people were divided into two populations and vaccinated at different rates was different.Therefore, for the current problem of continued spread of COVID-19, we consider the infectious disease dynamics model to achieve the goal of making the risk of infection of COVID-19 lower by controlling the proportion of vaccination of elderly and young people. In this paper, we divided young and old people into two groups, established an SVIWRD model, performed single-objective optimization using Pontryagin's maximum principle, and used the Runge-Kutta method for numerical calculation and simulation, so as to arrive at a certain vaccination ratio that plays the effect of reduced negative impact of COVID-19.