I am often asked by my clients when to apply ice and when to apply heat to an injury. Rule of thumb is: ice is always the safer bet. Generally, ice is applied when an acute injury occurs like a pull, sprain or tear, but that is not always the case. Sometimes nagging or lingering problems will require ice first to reduce inflammation prior to needing applications of heat (usually moist heat).
Most of us have heard of the RICE method but for those of you who haven't, R.I.C.E. stands for: Rest Ice Compression and Elevation and this is what I usually recommend. Rest the injured area, apply ice to the area for 15-20 minutes, allow the area to reach "room temperature" and apply a few times during the day. Compression just means to apply a little pressure to the ice pack so it's on teh injury and elevation is, well, having the area elevated so to reduce the amount of blood pumping to it to help cut back on the inflammation while you are icing it.
I don't generally recommend any OTC NSAIDS (over the counter, non-steroidal anti-inflammatory drugs) such as aspirin or ibuprofen because I don't take them myself but I don't tell people not to - I just warn them of side effects and what to look for.
Now to the hot stuff. Heat is applied when an injury is chronic. You know, that nagging stiffness you have in a muscle or joint or the "here today, gone tomorrow" type pain that we get as we age. Generally, I recommend heat in these situations to loosene the area up - but only prior to an activity, then I suggest icing post-exercise/activity to reduce any inflammation.
For further reading....