That was the question raised back in 2011 by science writer Brian Switek. Many people would probably say Journey to the Center of the Earth, which was first published in 1864. “Yet there were no dinosaurs,” Switek noted. “Marine reptiles, prehistoric elephants, pterosaurs and even primordial algae all make appearances, but there’s not an Iguanodon or Cetiosaurus to be seen.”
Switek identified the 1901 novel Beyond the Great South Wall as a likely candidate, with its description of a Brontosaurus (now Apatosaurus). But a sharp-eyed reader pointed to an even earlier effort: The 1888 novel A Strange Manuscript Found in a Copper Cylinder. According to Wikipedia, the plot is ” is set in an imaginary semi-tropical land in Antarctica inhabited by prehistoric monsters and a cult of death-worshipers called the Kosekin.”
Why did dinosaurs take so long to catch on in fantastic fiction? The truth is they really didn’t capture the public’s imagination until the start of the 20th century, when several American museums scrambled to find and mount dinosaur skeletons in what has been labeled the second Jurassic dinosaur rush. It was not that dinosaurs were unknown before then – it’s just that the fossils of other prehistoric animals, like sea reptiles, were better known. It probably also didn’t help that some early scientists, particularly O.C. Marsh, kept their finds hidden from public view.
Anyway, you can read Switek’s article at Smithsonian.com. And if you want to read a thorough history of dinosaurs in science fiction and fantasy, I recommend Dinosaurs in Fantastic Fiction by Allan A. Debus.