The origin of the term old chestnut is thought to be a play, The Broken Sword (1816) by William Dimond.

Transcript: Zav. “At the dawn of the fourth day's journey, I entered the wood of Collares, when suddenly from the thick boughs of a cork tree—” / Pab. (Jumping up.) “A chesnut, Captain, a chesnut.” / Zav. “Bah! you booby, I say, a cork.” / Pab. “And I swear, a chesnut—Captain! this is the twenty-seventh time I have heard you relate this story, and you invariably said, a chesnut, till now.” / Zav. “Did I? Well, a chesnut be it then. But, take your seat again.”
Excerpt from the play.