We propose and solve an optimal vaccination problem within a deterministic compartmental model of SIRS type: the immunized population can become susceptible again, e.g. because of a not complete immunization power of the vaccine. A social planner thus aims at reducing the number of susceptible individuals via a vaccination campaign, while minimizing the social and economic costs related to the infectious disease. As a theoretical contribution, we provide a technical non-smooth verification theorem, guaranteeing that a semiconcave viscosity solution to the Hamilton–Jacobi–Bellman equation identifies with the minimal cost function, provided that the closed-loop equation admits a solution. Conditions under which the closed-loop equation is well-posed are then derived by borrowing results from the theory of
Regular Lagrangian Flows
. From the applied point of view, we provide a numerical implementation of the model in a case study with quadratic instantaneous costs. Amongst other conclusions, we observe that in the long-run the optimal vaccination policy is able to keep the percentage of infected to zero, at least when the natural reproduction number and the reinfection rate are small.