I watched the anime many times but in the first episode of Detective Conan, both Vodka and Gin never mentioned their names. But later as the series continues, it looks like he knows their names even before Haibara appeared in the series.
Conan never learned about their codenames in the anime due to the plot modification, which makes a big plothole.
Detective Conan World's Wiki stated:
The first season of Detective Conan rarely featured the Black Organization because the anime writers wanted to downplay their presence. Two of the episodes at least, were altered heavily in light of this:
Episode 5, The Shinkansen's Bomb Case: The episode replaces the two men who shrunk Conan with lookalikes unrelated to the Black Organization. In the manga version of this case, Conan runs into the real pair and learns their code names (Gin/Vodka in the Japanese Version, Melkior and Kaspar in the English Version). Their replacement creates a continuity error in Episode 54, Game Company Murder Case. Conan recognizes their code names when Tequila speaks to them, yet Conan never learned their code names in the anime version of events.
As already mentioned, in the manga version, Conan first learned about their codenames in "The Shinkansen's Bomb Case" (vol 4, files 4-6) where he ran into them inside the train.
There, using the microphone bug gadget by Professor Agasa, he eavesdropped on their conversation and learned about Gin and Vodka, their codenames.