Let's use a simplified picture- classical light waves and a sharp edge of a homogeneous material with an index of refraction, where the light travels more slowly. As the light wave leaves the material, it does so continuously. So you could say that the wave accelerates suddenly on leaving the the material, but the wave is only gradually leaving. Thus the rate of change of the average velocity over a wave packet only changes continuously, without any sudden jumps. Adding further realistic details, such as the gradual tailing off of the electronic wave at the edge of the material, just smooths the picture out even more.
As for the energy, it goes as the frequency times the photon number, which are the same in and out of the material, allowing for some photons that reflect. Since the wave in the material is moving slower, it has a smaller wave packet. Its energy density is higher than that in the vacuum, but the energy is the same. You can think of some of the energy in the material as being in the electrons, oscillating around the positions they'd be in if there were no wave coming by.
Mike W.
(published on 04/06/2012)