How can I treat mastalgia myself?

Avoid caffeine. Mastalgia (breast pain) is caused by fibrocystic change of the breast, among other things. I tell patients to avoid caffeine and wire bras. Stimulation of the nipple or breast can also make breast pain worse. Wear a soft bra, even at night, and take ibuprofen. Some people think vitamin E or evening primrose oil help, don't overdo it though.
It often resolves. Is the pain cyclic, meaning it comes and goes with your menstrual cycle? If so, caffeine avoidance or evening primrose oil may help. It does take a few months, so don't expect instant results, and often cyclic mastalgia resolves on it's own. This is unlikely to be breast cancer, but persistent or focal pain needs to be worked up. Make sure your bra is the right size (it often isn't).