The paper considers a generic model for a turbofan engine coupled to electromechanical (EM) elements used for energy conversion and storage in electric form. The electromechanical systems apply torque to the engine shafts, allowing for controllable power injection or extraction to and from the engine. The standard proportional-integral (PI) control law used to command fuel flow for turbofan speed regulation is maintained for compatibility with industry practices, leaving the electromechanical torque to be specified. The paper adopts an optimal control approach for this purpose, where a weighted combination of electric energy consumption and fuel consumption is minimized subject to the dynamics of the electrified propulsion system. The solution for the optimal torques is given by linear state feedback plus bias, with gains calculated numerically from engine linearization data. Energy balance equations are derived and used to guide the optimization, evaluate the resulting power distributions, and check for errors. Simulation studies are presented for a chop-burst transient and for a realistic flight mission profile with environmental input variations. The paper shows the economic advantage of operating the engine with the electrified components. Specifically, fuel burn can be reduced in exchange for electric energy, which must be replenished, but at lower cost.