OK, since you can orgasm perfectly well when you masturbate - that means nothing is wrong with your ability to orgasm.
When you say your boyfriend touches you - do you mean he touches you in the same way you masturbate? If yes, they you have a psychological problem and need counseling.
If no, then teach him how you masturbate and have him learn to do it the same way you do.
If you answered yes above and you have a psychological problem - that could be causing you the pain during sex. Sex can be painful physically, but it can also be psychologically. He feels like real pain to you - it is real pain - but it may not actual have a physical cause.
If you answered no above, the problem could be a variety of things. If sex has always hurt you may be too small - have you ever masturbated with something inside you or inserted a tampon - did that hurt? It could be your position - some positions are more likely to hurt than others for women with specific bone structures - try different postions.
Let me know what of this makes any senss to your situation and maybe I can help you some more.
Susan