hurts to orgasm?

I haven't been able orgasm in a while because I've been sexually active with my partner but I could never cum no matter how much I tried with him. So I was masturbating and I came really quickly but then it kind of hurt. Was it just because I haven't been able to in a while or is this something I should check out?