I found if I freeze the frosting, it will stay good for up to 3 months (any longer and the flavor suffers). I simply use my biggest cookie scoop (muffin-size) to scoop the frosting onto waxed paper, and then put it in the freezer until the frosting is hard. Then I transfer the frozen frosting to a freezer zip-top bag, and put it back in the freezer. Having frosting in the freezer is awesome when you want to make some quick cupcakes, and my kids love to have it for dessert with graham crackers.
To use the frozen frosting, take the frosting balls out of the bag, put them in a bowl, cover them with plastic wrap, and let them thaw at room temperature. Give the frosting a gentle stir to restore the spreadable consistency, and you're in business.
Note: I've only done this with my buttercream frosting, which is made with butter and shortening. I don't think this will work with other buttercreams that are made with meringue, etc.