The OED has it from 1941 and originally Australian.
Origin uncertain; perhaps related to duff n.1 b, and hence analogous to similar slang phrases for pregnancy such as in the (pudding) club or to have a bun in the oven.
Duff n.1 b* is a flour pudding that's been boiled in a bag, or a dumpling. The a sense is simply dough. Of this they say:
originally a northern pronunciation of dough n.: compare enough.
The duff etymology is of northern England, dating to 1840. How did this get to Australia? Well, duff does appear to have been in use in Australia too, such as in the cake known as plum duff which can be found in Australian newspapers as far back as 1849.
An 1893 article relates the naming of this "great holiday dish of sailors" by a "boatswain's mate, a brawny son of the Emerald Isle" whose task it was to cook a Christmas pudding:
At last he settled upon a recipe which began,
" Make a stiff dough." When he reached the word
dough he said to himself, " If r-o-u-g-h spells luff,
d-o-u-g-h spells duff."
Well, this is probably folk etymology, but this sailors' cake is still known as plum duff in the antipodes today, and it's one of many examples of dough -> duff in 19th century Australia.