Often times the question is "Should I use heat or ice?". Both ease pain but consider what pain drives you to this question.
Generally when you’ve just done something to yourself like jamming a finger, rolling an ankle, or wrenching your back...use ice for the first 24-48 hrs. This is to combat the inflammation and swelling as well as to alleviate pain.
But for more chronic issues, that nagging neck pain or achy back...heat should be applied. It can be especially helpful before activity to “warm up” the muscles and joints, increasing blood flow, easing the pain and stiffness. After activity, then apply ice to “cool down”.
Apply both heat and ice for 10-20 minutes. Protect your skin from both with a towel as a barrier between your skin and a heat/ice pack. With acute injuries apply ice often, ~15 minutes, then allow an hour or so to rebound and apply again.
Maureen E. Regan PT