If you're gonna eat the cake within a day or 2 days then there's no need to refrigerate the cake.
I've bought cake in the store a few days before eating it and left it out of the refrigerator but if you're not gonna eat the cake within a few days then you should refrigerate it to keep it fresh and prevent mold growth.
If you do refrigerate the cake then you should wrap the cake in plastic wrap to seal out any potential refrigerator food smells that could be absorbed into the cake.
According to food safety it's very safe to leave a cake out at room temperature even with icing for a week and sometimes longer.
But refrigerating the cake makes it last longer.