This is a question I love to answer, and it’s much simpler than you might think. When in doubt, use ice. Ice is most useful when there has been an injury or there is inflammation. Sprain your ankle? Ice it. DO NOT heat inflammation!! Heat is best with tension, tightness, or true muscle spasm, which can be a 10/10 on a pain scale. Also, heat can be helpful if healing is slow by bringing more blood to the area providing healing nutrients to the involved tissues.
That’s it in a nutshell. Any questions?