The latest from Dr. Cheung: The answer is... it depends on the scenario. If you don't have a specific diagnosis for your condition, there are some general rules you can follow. Long-term issues (longer than a few weeks) benefit from heat because pain is primarily due to tight muscles. Tight muscles will loosen up with heat temporarily and you'll feel better. For new injuries that occur, I usually recommend using ice immediately to reduce inflammation and pain.
Although ice and heat are helpful, it's rarely the main way to completely fix an injury. Especially for long-term issues, heat and ice won't really fix the true cause of the problem but will offer temporary relief.