The basic elements of deterministic and stochastic optimal control theory are presented. The application of Bellman's principle of optimality in the stochastic context is described, along with the derivation of the Hamilton-Jacobi-Bellman equation. Using these tools, the investment-consumption problem of Merton is studied in detail.