Burning while having sex

So when my boyfriend and I are in the middle of sex, SOMETIMES my vagina starts burning and it's super painful. Luckily sometimes it goes away but other times it's so bad we have to stop. Also immediately after, it burns when I pee but it doesn't burn any time after that. Does anyone know what could be happening? 😩