Proliferation of large number of cloud users steered the exponential increase in number and size of the data centers. These data centers are energy hungry and put burden for cloud service provider in terms of electricity bills. There is environmental concern too, due to large carbon foot print. A lot of work has been done on reducing the energy requirement of data centers using optimal use of CPUs. Virtualization has been used as the core technology for optimal use of computing resources using VM migration. However, networking devices also contribute significantly to the responsible for the energy dissipation. We have proposed a two level energy optimization method for the data center to reduce energy consumption by keeping SLA. VM migration has been performed for optimal use of physical machines as well as switches used to connect physical machines in data center. Results of experiments conducted in CloudSim on PlanetLab data confirm superiority of the proposed method over existing methods using only single level optimization.