The bare expression beat them off with a stick is quite old, and started out as a literal statement of how to get rid of pests:
At the same time the hogs left the hut and rushed at him. He beat
them off with a stick he carried, and an occasional kick, and boldly
advanced to the hut. —Harvey Wilder, "Hippopotamus and Company", Our
Young Folks: An Illustrated Magazine for Boys and Girls, Volume 8,
John Townsend Trowbridge & Lucy Larcom, ed., 1872
"If I am sitting under a palm tree, and scorpions and wasps assail me,
I beat them off with a stick and with my hands." —Sabine
Baring-Gould, The Lives of the Saints, 1877
The earliest example I can find of a figurative extension of this concept to the idea of warding off romantic suitors who are so numerous as to be a nuisance is in the story A Man's Man by Ian Hay, originally published in Blackwood's Magazine in 1909:
"And you dare," she said, "to come to a girl like me with a proposal
like that! You sit there and tell me that you have taken me over from
Uncle Jimmy like a—like a parcel from a porter, and that you have been
saddled with my money and affairs, so perhaps it would be simplest and
save trouble if you married me! Me!" she repeated, "who have to
keep men off with a stick!"
The last sentence was a mistake. It was an inartistic and egotistical climax to a perfectly justifiable
I'm not sure whether the description of this phrase as "inartistic" suggests that it was Hay's own coinage or an already-established-but-clumsy cliche. However, it appears again a few years later in a romance novel:
"Doesn't like women!" echoed Monny Gilder. "He must be a curmudgeon.
Or has he been jilted?"
"Rather not!" Too impulsively I defended the absent. "Girls go mad
about him. He has to keep them off with a stick. He's got other
things to think of than girls, things he believes are more
important—though, of course, he's mistaken."
—Charles Norris Williamson & Alice Muriel Williamson, It Happened in
P.G. Wodehouse also used it in 1923, but to describe a different human annoyance:
Managers are just like sheep. They know nothing whatever about the
show business themselves, and they come flocking after anybody who
looks as if he could turn out the right stuff. They never think any
one any good except the fellow who had the last hit. So, while your
luck lasts, you have to keep them off with a stick. Then you have
a couple of failures, and they skip off after somebody else, till you
have another success, and then they all come skipping back again,
bleating plaintively. —P.G. Wodehouse, The Little Warrior, 1923
By mid-century it seems to have been fairly well-established in its current formulation:
There is a great deal of muscle involved, he's six feet ok and still
growing, and I imagine he has to beat the girls off with a stick.
—from an article in The Coronet, 1956 (snippet view)
Television's young Dobie Gillises have a new girl every week, its
young Margies an endless supply of would-be boy friends; the widower
in My Three Sons has to beat the women off with a stick . . . .
—Ernest Havemann, Men, women, and marriage, 1962
"I hear you have to beat the girls off with a stick." Pierre had a
devastating twinkle. —Elisabeth Ogilvie, How wide the heart, 1959
The earliest figurative usages are all by British authors, so I suspect this usage is British in origin. It seems to have been popularized to some extent in the context of the American entertainment industry later in the twentieth century, however, and usage of the verb beat rather than keep may partially be an American contribution.