How do airlines manage routes when respective aircraft undergo B,C or D checks?
Essentially they plan on some fraction of the fleet undergoing some sort of maintenance check at any one time, so they build their flying schedule around the remaining fraction.  And then there is some amount of flex due to things needing unscheduled maintenance or coming out of maintenance early.

What makes the task easier is the fact that maintenance needs can be forecast fairly far in advance, and so the schedules can be built around a knowledge of how many aircraft are likely to be available.

As an illustration (not necessarily representative of any particular airline's actual numbers), let's say you have a fleet of 200 aircraft, and you know that on average each aircraft will be down for two 2-week heavy maintenance checks each year.  That works out to essentially one month out of 12, each aircraft is down, or a little under 10% of the time.  Add in a little time for shorter maintenance visits (but still longer than an overnight), plus an allowance for the fact that some aircraft just need unscheduled work, and the maintenance planners may end up telling you to plan on 175 aircraft available each day.  So that's what you build your schedule around.

Now let's say that one aircraft takes a birdstrike &amp; an engine needs to be changed.  That is now a hole in the schedule.  It can be covered by cancelling a flight (undesirable, but always an option).  If an aircraft is finished with maintenance ahead of schedule (say it was scheduled down all day for some work, but the work is actually done by noon), that aircraft may be able to be put into service.  Perhaps it's possible to delay some sort of minor maintenance a day (not a heavy check, but something quicker) and essentially create one aircraft-day of capacity, and push the check off to a weekend day when the schedule uses fewer aircraft.  Or maybe the schedule was built with one or two aircraft available as spares that day.

Depending on a variety of factors, spares may or may not be available, or even deliberately built into the schedule at all.  Having an A-380 sitting around unused all day is an EXPENSIVE insurance policy against something unforeseen happening, but cancelling a flight on something that big is an expensive event when it happens!  If you operate all out of one giant hub and you know that your fleet of 500 aircraft (flying 450 lines every day) is likely to have 2-4 aircraft every day go to the hanger for unexpected maintenance, it's probably a good financial decision to allocate two or three of those lines as dedicated spares.  If your aircraft operate a point-to-point schedule, it's harder (or unfeasible) to keep a spare aircraft at every airport you serve, "just in case" something happens to break there.

There are complicated decisions that airlines will continuously evaluate to find what balance works best for their particular operation.  In some cases, it may be possible to substitute an aircraft from a different fleet for a broken jet... an MD80 goes to the hanger, and a 737 with a reserve crew flies the rest of the day that the MD80 would have flown.  Or maybe a 757 broke, and the decision is to use the 737 to cover the flight, and re-accommodate the extra passengers that the 757 could hold that the 737 now can't.  That's a tactical decision that the airline's operations center will make, considering the availability of both aircraft and crews, as well as the passenger loads.  (They also may pull a "healthy" 757 off of its less full schedule to fly in place of the broke 757, use a 737 that wasn't going to be very full to cover that 757's route, put an RJ on the 737's route that day, and cancel the RJ's flights "due to maintenance."  And if that inconveniences 4 flights of 40-50 people who mostly just get delayed a few hours, that's probably a better plan than stranding two flights of 200 people who'd otherwise have no way to get where they're going until tomorrow or later.)