Help!!!

So I'm 16 and so is my boyfriend, we've been together for a year and a bit now and it's great. 
I have an under-active thyroid so I am on medication for that as well as the pill to control my periods. 
My problem is that whenever we have sex it hurts me during penetration and during sex it feels sore and uncomfortable and I often don't feel anything because it's uncomfortable. Also after sex I'm often really sore. I have been to the doctor and he gave me tablets and a pessary but it hasn't helped. The only time sex hasn't been so bad for me is when we do it spontaneously and I haven't been anxious about it beforehand. Also we do not use condoms as I have a latex allergy. We have tried lube and it only makes a little difference. I know this is long but I really need some help😅 is it psychological? Or could there be something wrong with me? 😕