It really depends on the gun in question. If the gun is a self defense or duty handgun then I would clean it after every single shooting session. If the gun is for hunting then you should clean it when accuracy or reliability become compromised. My Browning Maxxus shotgun goes on many hunts before cleaning. I probably clean it once a year. It just doesn’t get that dirty.
Cleaning a gun insures functionality and accuracy. Todays primers and powders are non-corrosive and do not deposit large amounts of fouling. They are pretty clean burning.