We consider optimal vaccination protocol where the vaccine is in short supply. In this case, the endemic state remains dynamically stable; disease extinction happens at random and requires a large fluctuation, which can come from the intrinsic randomness of the population dynamics. We show that vaccination can exponentially increase the disease extinction rate. For a time-periodic vaccination with fixed average rate, the optimal vaccination protocol is model independent and presents a sequence of short pulses. The effect can be resonantly enhanced if the vaccination pulse period coincides with the characteristic period of the disease dynamics or its multiples. This resonant effect is illustrated using a simple epidemic model. The analysis is based on the theory of fluctuation-induced population extinction in periodically modulated systems that we develop. If the system is strongly modulated (for example, by seasonal variations) and vaccination has the same period, the vaccination pulses must be properly synchronized; a wrong vaccination phase can impede disease extinction.