What can be done when pain interferes with sleep?

Lots of choices. The bottom line is the improvement of your pain. Your sleep normalizes, if the pain subsides. This is easier said than done. Consider pain medication, relaxation therapy, acupuncture, a warm bath before bedtime, comfortable mattress, regular exercises, balanced diet and others. Sleeping pills have a very limited role.
Prevention. Not being able to sleep for any reason may indicated sleep problems that can be life shortening or life threatening. The only way to know if there are serious problems is with an overnight sleep test. I encourage you to seek help.