The aim of this paper is to present the design of a linear quadratic regulator (LQR) based on optimal control of single phase grid connected inverter with an LCL output filter used in solar applications. The converter model is set in the D-Q rotating reference frame where integral action is added to the grid current in order to cancel steady state error. The controller is tested in steady state, dynamic regime and for parameter variations. The simulation results carried out showed good performance and robustness of the adopted controller.