I had this through pregnancy, too. There's nothing quite so painful! Google nipple vasospasms. Have a look at your nipples when it happens- do they go white or purple, or both?
Unfortunately I continued to get them while breastfeeding, it was agony every time bub latched on. I think they continued because bub and thrush had done some damage to my nipples. You can get breastwarmers to tuck into your bra- they work well and definitely help, I got mine from mother's direct. There's also a medication you can take to settle them down, if they get really out of control while breastfeeding.
I took the medication in the end, it works instantly and eventually they settled down on their own and I'm still feeding my 8 month old, but the pain of these while feeding beats any other breastfeeding pain- thrush, cracks, you name it. I know, I had them all, lol!
I'm not trying to scare you, if you're going to breastfeed, as it probably won't happen to you. It's just that it took me so long to figure out what was going on, and convince my gp to help me. I wish I'd known about it all before.
Good luck for the rest of your pregnancy smile