From looking at several companies that sell cake and pie flavored teas, it appears that they use a couple of techniques that you may have uneven success with at home.
First off, you want to create a tea base that is as sweet as possible and creates a base flavor profile for you to use. Most companies achieve this by adding things like vanilla and rooibos to the tea. Vanilla is obvious, and rooibos has a smooth, slightly sweet, flavor reminiscent of pipe tobacco. Beyond this, many thenMany also have dried fruit or spices added, as fitting for the flavor you're working toward.
Beyond this, some of the companies use natural and artificial flavorings. As the website for David's Tea states, "The fact is, flavouring is the reason some of our favourite blends taste so great. We couldn't create the juicy melon flavour in Luscious Watermelon from dried melon alone."
You can add flavorings to your tea at home too, but they are very strong, so it may be hard to do it on a cup-by-cup basis. You may have better luck mixing the flavoring into a larger batch of tea. For things like cake and pie, I'd suggest adding butter flavor to mimic the pastry element, and an appropriate fruit flavor for pies. There are an amazing array of flavors available though, everything from "birthday cake" flavor to rosewater. Though they only sell to food service establishments, Gold Coast Ingredients' website illustrates some of the crazy flavors available. The teacup is your oyster!