In an atom you have energy levels. When an molecule goes from an upper electronic energy level to a lower electronic energy level, a photon of light is emitted which has an wavelength/frequency (remember c = f and E = hf) corresponding to the difference in energy between the two electronic states.
Taking the case of a diatomic molecule, as well as electronic energy levels there are also vibrational and rotational energy levels. Thus when a molecule changes state its electronic, vibrational and rotational states can all change.
For Rotational Levels: