The obvious reason for this is the pain. It will keep you awake and it will wake you up. It is therefor extremely important to plan your sleep around your medication schedule. Its also important to consider when you drink water as your throat gets very dry when you are sleeping.
The best strategy is to take your pain medication schedule and plan to eat about half an hour after taking your medication and then if possible fall asleep afterwards. This gives you the maximum time to sleep with the pain medication in your system. Most of the pain medication will wear off within 3-4 hours after which you may naturally wake up from the pain.
You need to decide whether you want to set an alarm to force you to wake up and take some more medication and drink water or to just continue sleeping. The advantage of waking up with an alarm is that you hydrate your throat and keep a constant level of pain medication in your system. As always I strongly recommend that you follow your doctors recommendation.