I use ice if I have any muscular or joint injury after exercise. the idea of the ice, I think is to keep any swelling under control. It is best used as soon as the injury occurs if possible.
I have also used cold water baths and showers to help recovery after long or hard runs, this again reduces any muscular tears sustained during the run.
Not so sure about the heat though. I would imagine there is some sort of alternating ice, rest, heat, rest session somewhere but I have never tried that.