In my experience as a nurse, pain in the hips, especially when sleeping on your side, can usually be attributed to an injury. Other than that, it can also be the kind of bed your sleeping on. Your mattress may be too thin, or too rigid and this pushes against the bony prominences in your hips, which, over a length of time, can cause pain.
There are several reasons your hips might hurt when you sleep on your side. Some of the most common reasons are bursitis of the hip or a having well-worn mattress and your hip is on one of the springs.
Mine have been like this since having my second child. If i sleep on my left side its my right hip that hurts and if i sleep on my right side its my left that hurts and its not my mattress coz i have a memory foam one now and its still the same.