Fog computing provides a platform for energy management-as-a-service by offering scalable and adaptable computing resources close to IoT devices, addressing limitations of cloud computing. The paper introduces fog computing for energy management and prototypes home energy management and microgrid energy management systems using fog computing's customizable control services to minimize costs and time to market. Experiments demonstrate energy management-as-a-service over fog computing platforms in residential and microgrid domains.