Goodness, unless there are other factors that I don't know, the advice you're being given is not correct.
If your baby is only 2 months old and you have 3 weeks of breastmilk pumped, then it's safe to say that you have an oversupply. THAT is probably why you have mastitis, your baby isn't capable of draining your breasts, which can lead to plugs, and the plugs can become infected causing mastitis.
What antibiotic are you on? Most are safe for breastfeeding, please don't pump and dump!!! At the very least, pump and store until you can find out if the drug is safe for breastfeeding. Some drugs that are safe include all variants of Penicillin, Erythromycin, Bactrim, Bioxin... I have had mastitis 5 times (3 times with my first son, and once with my second and third son). I have breastfed through all 5 bouts.
Another contributing factor to mastitis, aside from oversupply, can be thrush. Look up the signs/symptoms of thrush, if you think you or baby have it, then start treating it aggressively now. Start probiotics (you should be on them anyway since you're taking an antibiotic), get some gentian violet for you and baby, wash all your bras in a vinegar solution, change nursing pads at every nursing/pumping session, sterilize your pump, sterilize the baby's bottles/pacifiers, wash your bath towels after every shower, cut sugar out of your diet, etc.
How is baby's growth? Oversupply can cause a foremilk/hindmilk imbalance, and can sometimes cause baby to be excessively gassy, fussy, and to have poor growth. Does baby have green stools? That's a sure sign of foremilk/hindmilk issues. You will need to work to tame your supply, once you've recovered from the mastitis. You can decrease your supply by block feeding and pumping only to relieve engorgement and prevent plugs.
So I'd say first thing, is contact a Lactation Consultant to find out about the antibiotic. If it truly is contraindicated for breastfeeding, ask to be switched to a different antibiotic that is safe. Then get baby back on the breast!!! Work with the LC to find out what the root cause of your repeated mastitis is (for me with my first son it was deep tissue thrush with an oversupply, with my second son he had a poor latch due to a cleft palate, with my third son it's oversupply again). Then work with the LC to lower your supply a bit.