This paper solves the optimal power flow (OPF) problem for a power system with a battery energy storage system (BESS). The optimization problem is also extended to minimize the size of the BESS. Additional constraints must be included to ensure the battery's net energy over a duration is zero. It was found that the cost of a BESS solely based on load leveling cannot be justified. A BESS should also be employed in systems with (i) higher load variations, and (ii) different types of generators. Optimal sizing was performed based on the idea that only a portion of the BESS cost should associated with the benefits of load leveling.