A 12 gauge shotgun is a low intensity round. You would be way better off firing a shotgun in the confines of a building than any center fire rifle and a lot of common defensive handgun calibers. You can easily test this by firing a shotgun, rifle and a handgun at the range without hearing protection. (Yeah I know it's unwise to do this) I hunt with all three types of guns I mentioned and short of a 22LR rifle the shotgun is much more tolerable on the ears. Oh and muzzle breaks tends to make them much louder on you too.
Worrying about ear protection during a home invasion is generally ill advised. This is a circumstance where the keep it simple rule applies. The less you have to worry about the better off you are. You'll have a hard enough time just remembering to take the safety off.