There's a passage in Rudyard Kipling's Kim (1900: Gutenberg) where the main character (Kim) recites the multiplication table to himself to prevent himself from being hypnotized. I guess it depends on how broadly you construe "an earworm (broadly construed) as interference against psychic probing or attack?"
To save his life, Kim could not have turned his head. The light touch held him as in a vice, and his blood tingled pleasantly through him. There was one large piece of the jar where there had been three, and above them the shadowy outline of the entire vessel. He could see the veranda through it, but it was thickening and darkening with each beat of his pulse. Yet the jar—how slowly the thoughts came!—the jar had been smashed before his eyes. Another wave of prickling fire raced down his neck, as Lurgan Sahib moved his hand.
“Look! It is coming into shape,” said Lurgan Sahib.
So far Kim had been thinking in Hindi, but a tremor came on him, and with an effort like that of a swimmer before sharks, who hurls himself half out of the water, his mind leaped up from a darkness that was swallowing it and took refuge in—the multiplication-table in English!
“Look! It is coming into shape,” whispered Lurgan Sahib.
The jar had been smashed—yess, smashed—not the native word, he would not think of that—but smashed—into fifty pieces, and twice three was six, and thrice three was nine, and four times three was twelve. He clung desperately to the repetition. The shadow-outline of the jar cleared like a mist after rubbing eyes. There were the broken shards; there was the spilt water drying in the sun, and through the cracks of the veranda showed, all ribbed, the white house-wall below—and thrice twelve was thirty-six!
“Look! Is it coming into shape?” asked Lurgan Sahib.
“But it is smashed—smashed,” he gasped—Lurgan Sahib had been muttering softly for the last half-minute. Kim wrenched his head aside. “Look! Dekho! It is there as it was there.”
“It is there as it was there,” said Lurgan, watching Kim closely while the boy rubbed his neck. “But you are the first of many who has ever seen it so.” He wiped his broad forehead.
This passage is referenced in de Camp and Pratt's fantasy novel Castle of Iron (1962: Google books), where the protagonist is trying to resist a sleeping spell:
There was a story where you mustn't sleep. King of the Golden River? No ... Kim — and the boy there had used the multiplication table. The memory jerked him to effort. Three times three is nine ... if he could only keep on ... this part was too easy ... six times seven is forty-two ...
In A Wrinkle in Time (L'Engle, also from 1962), mind-control is attempted on the protagonists twice, once by the would-be controllers reciting the multiplication table, with the protagonists resisting by reciting nursery rhymes ...
And our decisions will be one, yours and mine. Don't you see how much better, how much easier for you that is? Let me show you. Let us say the multiplication table together.'
'No,' Charles Wallace said.
'Once one is one. Once two is two. Once three is three.'
'Mary had a little lamb!' Charles Wallace shouted. 'Its fleece was white as snow!'
'Once four is four. Once five is five. Once six is six.'
'And everywhere that Mary went the lamb was sure to go.'
... and the Gettysburg address. Later, the US Declaration of Independence and the periodic table of elements are used similarly.
As this blog post points out, this episode is referenced in a Babylon 5 episode, A Race Through Dark Places (1995).