Either in the shops or taking out of service credit.
The air brake system maintenance, flue time and periodic inspections (92 day) are all based on use. There isn't any distinction between operating just once a week or 7x24. If an engine is not really needed, it is stored serviceable. If it is out of service for 30 days or more, this time is taken as "credit" and the time for maintenance/inspection/replacement is extended for that amount of time (with some maximum limits). This can save a substantial amount of money.
For steam locomotives, this was especially important because the ICC (later FRA) required the flues to be replaced based on calendar time regardless of actual use (unless 30+ days credit is taken). Recent changes have allowed steam locomotives to consider primarily the the days the boiler is under steam, versus just a straight calendar.
Even diesels don't enjoy this exception!