Efficient allocation of energy resources to key physiological functions allows living organisms to grow and thrive in diverse environments and adapt to a wide range of perturbations. To quantitatively understand how unicellular organisms utilize their energy resources in response to changes in growth environment, we introduce a theory of dynamic energy allocation that describes cellular growth dynamics by partitioning metabolizable energy into key physiological functions: growth, division, cell shape regulation, energy storage and loss through dissipation. By optimizing the energy flux for growth, we develop the equations governing the time evolution of cell morphology and growth rate in diverse environments. The resulting model accurately captures experimentally observed dependencies of bacterial cell size on growth rate, superlinear scaling of metabolic rate with cell size and predicts nutrient-dependent trade-offs between energy expended for growth, division and shape maintenance. By calibrating model parameters with experimental data for the model organism Escherichia coli , our model describes bacterial growth control in dynamic conditions, particularly during nutrient shifts and osmotic shocks. Integrating both the mechanical properties of the cell and underlying biochemical regulation, our model predicts the driving factors behind a wide range of observed morphological and growth phenomena with minimal added complexity.