The most efficient way to save energy in cellular networks is to switch ON/OFF base stations (BSs) dynamically according to the distribution of user equipment (UE) at real time. When a BS is switched ON/OFF, there is a switching energy cost incurred, which is a significant amount and cannot be ignored. By considering this switching cost, we formulate the energy saving problem of BSs in cellular networks as the minimum energy cost problem (MECP). The objective of MECP is to choose the BSs to be active during a period of time and determine the levels of transmission power of the active BSs according to the UEs that are served by the BSs, such that the total energy cost of the BSs is minimized. We propose a scheme to solve the MECP in two steps. In the first step, we aim to minimize the energy cost of all BSs in a time unit independently, without considering the switching ON/OFF BSs across adjacent time units. In the second step, we consider the switching cost of state transitions of BSs by introducing a state transition graph a BS over an entire time period, and transform the MECP into a minimum energy cost flow problem. A minimum cost flow algorithm is developed to solve this problem. Simulation results show that our proposed scheme can achieve significant energy cost reduction of the cellular network, compared with the existing methods.