Stochastic optimal control is a mathematical procedure used to find optimal solutions when dealing with a stochastic decision problem. As stated by the name, the decision problem is governed by a control (usually a function of time) that can be set in order to optimize the objective function. I will show the mathematical framework standing behind the formulation of the problem, and the theorems and steps that lead to the optimal solution. Many of these optimization problems belong to the financial and the actuarial fileds. Interested by these techniques, I applied this approach to a problem concerning the Italian pension system. I built a model that mirrors the aforementioned pension problem and I used stochastic optimal control techniques to find the optimal investment strategy. The closed-form solutions are presented and some Monte Carlo simulations are carried out to show how the optimal investment strategy varies with respect to parameters variation.