The joke is that the word 'habit' is the term for the kind of hat he's wearing.