Preheat oven to 350°F (175°C). Grease and flour two 8-inch round cake pans.
In a bowl, whisk together flour, baking powder, and salt.
In a separate bowl, cream butter and sugar until light and fluffy. Add eggs one at a time, then stir in vanilla.
Alternately add dry ingredients and milk, mixing until smooth.
Divide batter evenly between prepared pans and bake 25–30 minutes, or until a toothpick comes out clean. Cool completely.
Make the Custard Filling:
In a saucepan, heat milk until warm.
In a bowl, whisk together sugar, egg yolks, and cornstarch. Slowly pour in the warm milk, whisking constantly.
Return mixture to the saucepan and cook over medium heat until thickened. Stir in vanilla extract and let cool.
Assemble the Boston Cream Pie:
Place one cake layer on a serving plate and spread the custard evenly over the top.
Place the second cake layer on top.
Prepare the Ganache:
Melt chocolate with heavy cream (if using) over low heat or in a microwave until smooth.
Pour ganache over the top of the cake and spread evenly. Let set before slicing.
