Pumping processes often require different operating conditions for the same pipeline. The conditions downstream in the pipeline can change in such a way that the pressure at the discharge of the pump may vary, which automatically introduces changes in the flow supplied by the pump into the pipeline due to the head vs flow characteristic curve of the pump. Even under varying pipeline pressure conditions, it may be necessary to keep the flow discharge of the pump constant. The two most commonly used control strategies for flow control with centrifugal pumps are by means of a fixed-speed pump and a control valve at the outlet of the pump, or by means of a variable frequency drive which avoids the need for the control valve. It has been demonstrated that the approach with the fixed-speed pump and the control valve provides poor power efficiency results, so a variable frequency drive is normally the solution of choice in industry applications. The use of a variable frequency drive allows reaching the flow required by the system without changing the physical characteristic of the pump or pipeline, i. e., it is not necessary to shut the system down to replace the impeller of the pump. However, affinity laws of centrifugal pumps dictate that a change in the rotational speed of the impeller shifts the characteristic curves of the pump, not only the flow vs head curve, but also the efficiency curves, among others. Besides, searching for a different operating point by changing the speed of the pump does not necessarily guarantees optimal operating power efficiency. This paper proposes an optimization approach where a compromise is made between flow control and power efficiency by minimizing the error in the flow rate while at the same time maximizing the power efficiency. To accomplish this goal, this paper presents the modeling of the pump and pipeline, and the design of a linear quadratic regulator control for the fluid flow passing through a given pipeline. The fluid under consideration is water. The mathematical model of the overall system is derived by considering the model of an AC motor, the pump and the hydraulic circuit. Then, with the help of the software MATLAB, the controller was designed and implemented with the linearized mathematical model. The actuator of the control system is the variable frequency drive that changes the speed of the impeller to adjust the flow rate to the required operating point under different loading conditions. The results show the behavior of the compensated system with the optimal controller. In practice, the control system must take into account the constraints of the control effort, which means, the frequency of the pump must be kept within safe values to achieve proper functioning of the pumping system.