Many public health threats exist, motivating the need to find optimal intervention strategies. Given the stochastic nature of the threats (e.g., the spread of pandemic influenza, the occurrence of drug overdoses, and the prevalence of alcohol-related threats), deterministic optimization approaches may be inappropriate. In this paper, we implement a stochastic optimization method to address aspects of the 2009 H1N1 and the COVID-19 pandemics, with the spread of disease modeled by the open-source Monte Carlo simulations, FluTE, and Covasim, respectively. Without testing every possible option, the objective of the optimization is to determine the best combination of intervention strategies so as to result in minimal economic loss to society. To reach our objective, this application-oriented paper uses the discrete simultaneous perturbation stochastic approximation method (DSPSA), a recursive simulation-based optimization algorithm, to update the input parameters in the disease simulation software so that the output iteratively approaches minimal economic loss. Assuming that the simulation models for the spread of disease (FluTE for H1N1 and Covasim for COVID-19 in our case) are accurate representations for the population being studied, the simulation-based strategy we present provides decision makers a powerful tool to mitigate potential human and economic losses from any epidemic. The basic approach is also applicable in other public health problems, such as opioid abuse and drunk driving.