Two optimization problems are considered: Harvesting from a structured population with maximal gain subject to the condition of non-extinction, and vaccinating a population with prescribed reduction of the reproduction number of the disease at minimal costs. It is shown that these problems have a similar structure and can be treated by the same mathematical approach. The optimal solutions have a ‘two-window’ structure: Optimal harvesting and vaccination strategies or policies are concentrated on one or two preferred age classes. The results are first shown for a linear age structure problem and for an epidemic situation at the uninfected state (minimize costs for a given reduction of the reproduction number) and then extended to populations structured by size, to harvesting at Gurtin–MacCamy equilibria and to vaccination at infected equilibria.