Regularity of solutions of a second order hamilton-jacobi equation and application to a control problem