Bilbo tells him
If you don't mind an answer from the book that is...
'What's he got in his handses?' said Gollum, looking at the sword, which he did not quite like.
'A sword, a blade which came out of Gondolin!'
'Sssss,' said Gollum, and became quite polite. 'Praps ye sits here and chats with it a bitsy, my preciousss.'
The Hobbit - Chapter 5 - Riddles in The Dark
As Gollum then become very meek one can assume he has heard of Gondolin and knows it is elvish, other than just a random sword.
We can assume that Bilbo himself finds out his "sword" is from Gondolin when Elrond examines the swords in Rivendell:
Elrond knew all about runes of every kind. That day he looked at the swords they had brought from the trolls' lair, and he said:
'These are not troll-make. They are old swords, very old swords of the High Elves of the West, my kin. They were made in Gondolin for the Goblin-wars. They must have come from a dragon's hoard or goblin plunder, for dragons and goblins destroyed that city many ages ago.
This, Thorin, the runes name Orcrist, the Goblin-cleaver in the ancient tongue of Gondolin; it was a famous blade.
This, Gandalf, was Glamdring, Foe-hammer that the king of Gondolin once wore. Keep them well!'
The Hobbit - Chapter 3 - A Short Rest
This does lead to the question, where Gollum hear about Gondolin?
Probably from the same source given in Po-ta-toe's answer where he heard about Gondor, and how he learnt about the Battle of Dagorlad.
The Dead Marshes. There was a great battle long ago, yes, so they told
him when Sméagol was young, when I was young before the Precious came.
It was a great battle. Tall Men with long swords, and terrible Elves,
and Orcses shrieking. They fought on the plain for days and months at
the Black Gates.
The Lord of The Rings - The Two Towers - The Passage of the Marshes