Does energy of light change when a light travels from a medium to another of different optical density?
It depends on what you mean by the energy of light.
A light wave has an associated energy flux, that is how much energy passes through a surface at right angles to the light ray. This energy flux is a constant and doesn't change when a light wave passes through materials of different refractive index.
However, since the velocity of light is reduced in a medium of higher refractive index if the energy flux stays the same then the energy per unit area at the surface must increase. In this sense the energy of the light does change when passing through media of different refractive index.