See Also - Bavarian Cream Recipe; Cream Trivia
BAVARIAN CREAM : CRÈME BAVAROISE
Bavarian cream was originally a French (or German?) cold dessert of egg custard stiffened with gelatin, mixed with whipped cream (sometimes with fruit purée or other flavors), then set in a mold, or used as a filling for cakes and pastries.
No one is sure about the origin of Bavarian cream, but during the late 17th and early 18th centuries many French chefs worked at the court of the Wittelsbach Princes (a German family that ruled Bavaria from the 12th century to 1918). This would have given them the contact to have learned it in Bavaria. The famous French chef Carême (1783-1833) gives recipes for it in the early 18th century.
The suffix 'crème' in German speaking lands, is the term for the gelatin mold - (Schokolatencreme, Weincreme, etc.) and there are many variations, flavored with chocolate, lemon, kirsch, etc.
So - in summary, the most likely origin is that the French chefs working for the Bavarian rulers (the Wittelsbachs) learned something either the same or very similar while working in Bavaria, and when they returned to France continued to make it, and called it Crème Bavaroise (Bavarian Cream). And since, in addition to being served in a gelatin mold, it was also used as a cake filling, the next step to its use as a doughnut filling at Dunkin Donuts was inevitable.