Hips and sex

Every time my boyfriend and I have sex and I get on top my hip will start to bother me and tonight they even locked up to the point I couldn't move my hips or legs.. It only happens when I'm on top.

Any advise regarding this subject would be greatly appreciated