Taking a warm bath or placing an ice pack or heating pad on your knee for 10 minutes can help prevent knee pain at night. Be sure to not place any ice packs or heating pads directly on your skin, as this could cause frostbite or burns.
Elevating your knee with a pillow or placing a pillow between your knees and sleeping on your side could also help. OTC medications such as NSAIDs should be used as directed.