Gandalf certainly did not realise that Bilbo's ring was the One Ring at the end of The Hobbit, or indeed by the start of The Lord of the Rings. The realisation came upon him slowly, and he only fully worked it out years after the start of The Lord of the Rings.
"How long have you known all this?" asked Frodo again.
"Known?" said Gandalf. "I have known much that only the Wise know, Frodo. But if you mean 'known about this ring', well, I still do not know, one might say. There is a last test to make. But I no longer doubt my guess.
"When did I first begin to guess?" he mused, searching back in memory. "Let me see - it was in the year that the White Council drove the dark power from Mirkwood, just before the Battle of Five Armies, that Bilbo found his ring. A shadow fell on my heart then, though I did not know yet what I feared. I wondered often how Gollum came by a Great Ring, as plainly as it was - that at least was clear from the first.
And I waited. Until that night when [Bilbo] left this house. He said and did things then that filled me with a fear that no words of Saruman could allay. I knew at last that something dark and deadly was at work. And I have spent most of the years since then in finding out the truth of it."
-- The Fellowship of the Ring, chapter 2: The Shadow of the Past