Though you can use your freezer to preserve cake for a few months after baking, you can't preserve it forever. Freezing cakes only slows down the process of going stale -- it doesn't stop it completely. The length of time you can preserve your cake ultimately depends on both the type of cake and how you wrap it.
The Fridge vs. the Freezer
Whether your cake is frosted or not, you can preserve it for several days at room temperature -- a week, maximum. If you want to prevent bacteria from growing in the cake as it sits -- a more significant risk in warm, humid temperatures -- wrap your cake in plastic or place it in an airtight container and store it in the refrigerator. To preserve a cake for more than a week, you need to freeze it. Unfrosted cakes and cakes with buttercream icing can last for about three months in the freezer when properly wrapped in plastic and foil or sealed in an airtight container. Some cakes, though -- like those with fruit filling or whipped cream frosting -- do not freeze as well, and may dry out in the freezer.