In this paper we consider a variation of the Mertons problem with added stochastic volatility and finite time horizon. It is known that the corresponding optimal control problem may be reduced to a linear parabolic boundary problem under some assumptions on the underlying process and the utility function. The resulting parabolic PDE is often quite difficult to solve, even when it is linear. The present paper contributes to the pool of explicit solutions for stochastic optimal control problems. Our main result is the exact solution for optimal investment in Heston model.