Icing is used to treat acute injuries and chronic conditions immediately following (up to 48 hours after) activity. It reduces inflammation and swelling.
Heating is typically for chronic conditions. It helps stimulate blood flow and relax tissues. Apply before activity or after swelling has subsided. Do not use to treat acute injuries.
Here's a good tip-
"Don't get yourself into an endless cycle of using heat to loosen up a joint, then injuring it through overuse, and then icing it to bring down the swelling, only to repeat the same pattern the next day. If this sounds like something you do, consider taking six weeks off from the activity in question, and then building back up to it gradually and safely. Heating and icing should be a means of first aid, not a way of life."
i.e. get yourself healthy (pain-free) and rehab (strengthen) the problem area with proper training. Yes, this is going to take awhile to do it right.