If you're having some knee pain and it's fairly acute or sub-acute in origin there's only one way to go. You're going to want to use ice to help you with this pain for a couple of reasons. The ice first of all is what's called a vasoconstrictor, meaning it's going to constrict the blood vessels heading towards that joint area. Less blood to the area can really help promote the reduction of your swelling problem that's going on in the beginning.
The other reason why the ice is beneficial is because it can literally sort of numb the painful receptors inside the joint, so there's this temporary feeling of improvement and decreased pain. If you do it every day or maybe once or twice a day, you can sort of have a carry-over effect and speed up the recovery, as well.
The heat option is really good to soothe muscles. It's something down the line after you've been doing some exercising. Your joint problem is under control, but now your muscles are a little sore from over exercising and that's where the heat's going to come in. But by and large, you're going to want to ice your knee in the presence of acute pain or sub-acute pain. Once a day might be successful. Twice a day is probably better.
Timeline-wise maybe a 10-minute interval, maybe 15 minutes at the most depending on how cold the ice is. If you're literally using ice cubes and putting it in a bag, you might want to put a cloth between your skin and the actual ice cubes. If it's too cold, it can actually irritate the skin some, so you might want to put a layer of cloth in between. If it's an ice pack that you can get at the CVS or Rite-Aid, that can go right on your skin for about 10 to 15 minutes, so definitely ice, compared to heat.