Just like cars, airplanes have a comprehensive maintenance schedule that airlines must follow. Maintenance is scheduled based on the number of cycles (takeoffs and landings) as well as additional inspections based on the age of a plane.
The 747-400 is no different. Every 5 years a 747-400 has to undergo a ‘D-check’ inspection. The inspection isn’t cheap. They cost almost $3M as they strip the aircraft for a very thorough inspection and cleaning.