How did Sauron know to torture Gollum on the whereabouts of the ring? We know that Gollum said "Baggins" and "Shire" while being tortured, but why did they think he might know in the first place?
The canon indicates that Gollum left his home under the Misty Mountains to seek out the ring after the events of "The Hobbit," but that it took him some time to work up the necessary courage to do this. Presumably, Bilbo was already back in The Shire by the time Gollum was finally brave enough to go out looking. Gollum searched to the East originally (the direction that Bilbo first went upon leaving with the ring) and eventually Gollum ended up down near Minas Morgul (he had encountered Shelob before the events from "The Return of the King"). But he got caught snooping around Mordor. He would have been questioned or tortured just for that alone, without any hint that he knew anything about the ring. Maybe Sauron's torturer learned that Gollum knew about the ring just during an otherwise routine torture session on this strange creature found snooping around Mordor.