Cold therapy is most often recommended for acute pain. The following two reference articles may help:
"Cold treatment reduces blood flow to an injured area. This slows the rate of inflammation and reduces the risk of swelling and tissue damage. It also numbs sore tissues, acting as a local anesthetic, and slows down the pain messages being transmitted to the brain. (Cold therapy) can help treat a swollen and inflamed joint or muscle. It is most effective within 48 hours of an injury. Rest, ice, compression and elevation (RICE) are part of the standard treatment for sports injuries." *
*Heat and cold treatment: Which is best? (medicalnewstoday.com)
Note that Cold Therapy should not be applied directly to the skin.
"One exception: If you have chronic pain and wish to exercise, the recommendation is to use heat before to increase the blood flow to the area, which helps muscle flexibility and joint movement. "Once you've completed the activity, switch over to ice in order to prevent any new inflammation that may come about from whatever the exercise or activity was that was just completed", says Elizabeth Gardner, MD, orthopedic sports medicine surgeon at Yale Medicine and head team orthopedic surgeon at Yale University Athletics in New Haven, Connecticut." *
*Hot Therapy and Cold Therapy At-Home Treatment Tips for Chronic Pain | Everyday Health