Should academic papers necessarily carry a sober tone?
Are jokes or anecdotes fine as long as they do not appear forced?
To me, there is a single measure for this: does a sentence X contribute to the paper, or not. If the answer is no
, it shouldn't be there at all.
To apply the principle to the joke: if the joke illustrates a common problem which needs a solution, or illustrates a common (perhaps insufficient) solution to a well stated problem, then it certainly has a place in a research paper.
I understand scientific writing as a form of literature. I do not see any reason for literature (including scientific discourse) not to be entertaining as well, when appropriate. But everything has its time and place. However, it shouldn't be forced and has to fit the main contribution of the paper, hence the filter rule above.
Quoting Terry Tao:
Overly philosophical, witty, obscure or otherwise “clever” comments should generally be avoided; they may not seem so clever to you ten years from now, and can sometimes irritate the very readers you want to communicate your result to.
However, you'll always be a little embarrassed looking back at yourself, so this is a pretty mild warning. I think there's nothing wrong with a little humor in papers.
That said, your example joke is definitely inappropriate to put in a formal paper because it's a joke that assumes the audience is all straight men. There may be a place for mildly sexist humor, but that place is not the workplace.
To add to walkmanyi's good answer: To make jokes in a scientific article is "dangerous". It is similarly a bad idea to use "quotes"! In both cases the reader may interpret the written text in many different and unforeseen ways. It is particularly problematic since readers come from many different cultures and different ways of expressing themselves, for example, figuratively. Since clarity should be a key aspect of an article, it is best to stay clear of jokes and such, keeping the somber tone you refer to.