If there is a pain in my knee and I can't sleep, what should I do?

Treat pain. Treat the pain. If there is problem with pain, your brain tended to have wake rhythms intrude into sleep. Sleep can be lighter and less restorative. Treat the pain. Try antiinlammatory first unless there is reason not to and heat/ice. See a doctor if this is not helping.