When you are injured, or your pain suddenly increases, you should use ice. This stops pain and slows down swelling. If you have the same achey, soreness day in and day out, you can use heat.
Ice is used to slow down the blood flow by constricting the blood vessels, which slows down the swelling and inflammation. Heat increases blood flow by dialating the blood vessels, which increases inflammation and swelling. Therefore, in an acute situation (a new injury, increase in pain and swelling), you would want to use ice.
I recommend using gel ice pacs because they are more comfortable. Also frozen peas or corn work well too. DON'T put ice directly on your skin! Always have a layer between your skin and the ice pac. You can actually burn your skin with direct contact. A paper towel, or thin dish cloth works best. Don't use a towel because of the thickness. You want the area to get cold. A thick towel won't allow the proper temperature change to the area.
A good rule of thumb is 15 minutes after the area gets numb. First, you will feel a burning, then an ache, and then it will go numb. Ice doesn't feel as soothing as heat, but it works best for acute symptoms, and will help control swelling and inhance recovery.