A collection of the English language's greatest books and manuscripts, from Beowulf to Beatles lyrics by way of the Magna Carta, Shakespeare, James Joyce, and more
The generic British word for dessert is "pudding."
In the 19th century, the "g" was sometimes pronounced as a harder "k." Sometimes, the "n" got dropped. Sometimes that was shortened by slicing off the "pud."
In other words, small, incremental changes resulted in pudding->puddink->puddik->dick.
It's not meant to be dirty; it's just a Victorian synonym for "dessert."
Pepper a cake with currants or raisins, and you get "spots" in your pudding, hence: spotted dick.