Spray foam is used on the exterior side of electrical boxes installed in exterior walls to ensure maximum energy efficiency.