In this paper, an optimal proportional integral derivative (PID) controller based on a linear quadratic regulator (LQR) is proposed for the regulation of the output voltage of a buck converter. Specifically, the work proposes to determine the gains of the PID controller through an LQR state feedback technique, formulated as a Linear Matrix Inequality (LMI), which allows for ensuring stability and guarantee a predefined performance index. Simulation results using PSIM are presented validating the theoretical study.