I am planning to take my 5 year old on a trek through Peru. One of the places to visit is Machu Picchu. Given its location above sea level I was wondering how long of an adaptation period we should take before visiting if any? And considering the 5 year old how should this be adjusted?
Machu Picchu itself is only around 2400 metres above sea level - well below the altitude that most people would suffer any real effects of altitude sickness, and about 1000 metres lower than Cuzco (3400 metres) where most people visit before heading to Machu Picchu.
If you are planning to trek then it really depends on which path you take.
The "Inca Trail" (specifically the path from KM88 to Machu Picchu which is what most people take) is ~ 42km, and reaches altitudes up to 4200 metres at which point most people will at least have some difficultly with the thin air, especially when going up-hill (You'll never look at a single flight of ~20 stairs the same way again!). ~38km over the first 3 days is going to be difficult for most 5 years old, even without the altitude. (The 4th day is the last ~4 km, and mostly downhill so less of an issue)
There are other options of varying difficulty and altitudes. Some of these do go higher than the Inca Trail (eg, Lares gets up to over 4500 metres), although all will only stay at those altitudes for short periods of time, before dropping back to lower altitudes to sleep. Without knowing what distances you're looking for it's hard to make a recommendation on what might me suitable.
An additional option is to take the bus to Machu Picchu (train from Cuzco to Aguas Calientes where you can stay the night and catch the bus early the next morning). You can still reach Machu Picchu around/before sun rise, and do a day hike up Huayna Picchu - the peak you often see "behind" Machu Picchu in photos.
If you are heading to higher altitudes then generally a day or two in Cuzco will give you suitable time to acclimatize. Cuzco itself is an amazing place, and even ignoring the need to acclimatize I'd suggest spending at least 2 days there to see the city itself and the surrounding areas.
Essentially what you're asking is covered quite extensively in "Avoiding or minimising altitude sickness".
In terms of Machu Picchu, be aware that the treks are NOT easy walks. The Inca trail is a long, difficult walk. Extremely fit and active relatives and friends found it to be, and I quote "the hardest thing I've ever done in my life". You're in the wild, and it may be too much for a five year old. I'd consider trying to find out from others who have taken children about whether they coped, but otherwise consider one of the easier shorter walks, or just take the fun way - the train up to Aguas Calientes from Cusco.
In terms of where to acclimatise, most seem to spend a few days in Cusco acclimatising there. Definitely take the time to do so - just walking around in Cusco you notice the effort required is more than expected.
Still, once you reach Machu Picchu at sunrise, believe me, it's totally worth the effort of getting there! :)