From the internet:
Anyway, I didn’t realize there was a mystery. Then I looked up the expression in the “Morris Dictionary of Word and Phrase Origins” by William and Mary Morris (HarperCollins, New York, 1977). It says: “…carrot and stick. A riddle that seems to have confounded many students of language is the origin of the carrot and stick expression. Research in Aesop’s Fables, the Uncle Remus folk tales and other such sources didn’t turn up any answers.”

Mr. and Mrs. Morris cite a couple of instances where the expression was used -- a speech by Winston Churchill and the movie “Maltese Falcon” but it sounds like the animal was tempted with a carrot and beaten with a stick. I am sure this is wrong. The stick is used to keep the carrot out front, not to hit the animal. Mr. Churchill in a press conference, May 25, 1943, states: ‘We shall continue to operate on the Italian donkey at both ends, with a carrot and with a stick,”…

I hate to say this but I believe Mr. Churchill and Mr. and Mrs. Morris got it wrong.