The talk is intended to provide a pedagogical introduction to optimal control theory in continuous time and to its connections to PDEs. I will present the main ideas of the Dynamic Programming approach for a family of optimal control problems, both in the deterministic and in the stochastic framework. Some applications in economic growth theory and epidemiological models will be illustrated.