Having heard the tale of Hansel and Gretel orally, the brothers Grimm published it in 1812. One of its most memorable themes is the witch's house made of sweets. Does such a theme predate this tale? And if so, when did it first appear?
Yes, the theme of a house constructed of sweets does predate the Hansel and Gretel tale.
It appears in the fantasy The Land of Cockayne which was included in a 14th century manuscript from Ireland, the earliest known literary text in English from that country.
Sources: John Thomas Koch, Celtic Culture: A Historical Encyclopedia, 1976; Elaine M Treharne, Medieval Literature: A Very Short Introduction, 2015; Iona Opie and Peter Opie, The Classic Fairy Tales, 1974.
According to the “Enzyklopädie des Märchens,” Vol 3, in the entry for “Dach” (roof) it is stated on pg. 206 (my translation, loosely paraphrased):
In Schwankmärchen [Farcical tales] of Schlaraffenland (AaTh 1930) the roofs are in contrast decked with delicatessens: in the French Fabel de Cocaigne (13. Jh.) with fish, bacon, and sausages, in Geiler von Kaisersbergs Navicula sive speculum fatuorum (1510/11) with Pfannkuchen [pan-cakes], in Hans Sachens poem Das Schlauraffenland (1530) with Fladen [pan-cakes] in Wrozki by the Pole Podworzecki (1589) with sides of bacon and dumplings etc. In Hänsel und Gretel the witch’s house is diabolically necessarily built out of bread and with covered with cakes (cf. Mot. F 771. 1. 10: Gingerbread house).
Note: the house is made of bread, the roof is decked with cake and the windows were made of clear sugar (hellem Zucker). “Gingerbread” probably came from an English translation. The text of Hänsel und Gretel is from various tellings from Hessen. Told by Henriette Dorothea Wild (1793 – 1867).
From my translation of the Grimms 1810 Manuscripts:
“Handwritten Note in the 1812 Vol I Gräter has the Märchen of the sugar-house-let in Schwab. Dial. instead of [the] old woman sits a wolf in [the] house-let.”
“1812 Appendix Additions in the 1815 Vol II Num. 15. (Hänsel und Gretel.) Compare the entrance of nennillo e nennella in the Pentamerone. One also has this beautiful Märchen so, that instead of the old one a wolf in the sugar-house-let sits and still more rhymes with it occur.”
“The 1975 Rölleke text states that the origin of the Märchen is uncertain, but since it is in Jacobs handwriting, the source is possibly the Hassenpflug family. At the end of the text there are handwritten notations: “Svend Tomling” and “Nyerup n. 46.” The note refers to Rasmus Nyerups “Verzeichnis der Almuens morskabsbøger” in Iris og Hebe 1795/96, July p.88; no. 46: Svend Tomling. The 1810 text was added to the 1812 Anhang to No. 15 Hansel and Gretel.”