We analyze a mean field game model of SIR dynamics (Susceptible, Infected, and Recovered) where players choose when to vaccinate. We show that this game admits a unique mean field equilibrium (MFE) that consists in vaccinating at a maximal rate until a given time and then not vaccinating. The vaccination strategy that minimizes the total cost has the same structure as the MFE. We prove that the vaccination period of the MFE is always smaller than the one minimizing the total cost. This implies that, to encourage optimal vaccination behavior, vaccination should always be subsidized. Finally, we provide numerical experiments to study the convergence of the equilibrium when the system is composed by a finite number of agents ($N$) to the MFE. These experiments show that the convergence rate of the cost is $1/N$ and the convergence of the switching curve is monotone.