Another cause of pain can be a milk blister or bleb. These are really common in the early months of breastfeeding and are basically where the skin on the breast overgrows one of the milk ducts and blocks it. They look like a little white dot on your nipple and are quite painful when your baby breastfeeds.
This photo show a milk blister but it is a little hard to see as they are so small. It is the very small white dot in the upper part of the nipple.
What to do if you have a bleb:
I actually had a few blebs myself but didn't know what they were and was in the middle of other problems like poor attachment and developing mastitis. The actual bleb hurt a fair bit but my little guy did end up sucking it out in about 4 days.