Like any mechanical device, you should take good care of your firearms. While debate rages over just how often and thoroughly you should do it, gun cleaning is a must for any serious firearms owner. Most manufacturers will provide general guidelines on maintenance yet few address how often. Based on my knowledge and experience I can provide you with what has worked for me over the past 30 years.
Regardless of the type of firearm, it should be at least wiped down and oiled following any range session. If the session is long and you run several hundred rounds, I suggest that you field strip the gun and wipe the internals. Use a bore snake on the barrel and oil all moving and metal-on-metal surfaces. For prolonged sessions or those that take you into dusty or dirty environments you should deep clean your gun. At this point it is important to encourage you to seek professional training on dissembling your gun beyond a field strip. With that being said, when needed, break the gun completely down and clean it thoroughly. The use of an ultrasonic cleaner is helpful for parts that are tough to get into.
Firearms are investments and more importantly can end up being used in the defense of your life. Maintain them and they will serve you well.