In most cases it is prudent to try ice first following an injury. Ice is one of the strongest anti-inflammatories. In the first 72 hours after an injury there is significant swelling. The ice decreases blood flow to the area and reduces swelling. A cold pack should be applied to the area of complaint. It is very important that you wrap the ice in a towel and NOT put the ice pack directly on your skin or it may cause frostbite and the Huntington reaction can occur (a phenomena whereby the body instinctively starts bringing blood to the area and heating the tissues to try to conteract the thought that it is being frostbitten). Ice is recommended for sprains and strains and general pain, swelling and bruising. I recommend 15-20 minutes of ice time only and to wait at least a full hour before icing the area again.
Heat can be used for chronic complaints. It helps to relax tight muscles and stiff joints and can be useful for arthritis discomforts. I recommend no longer than 20 minutes of moist heat wrapped in a towel so that you do not burn your skin. For athletic overuse injuries heat is recommended before the activity or sport and ice is indicated after play if there is swelling present.