I suppose Wormtongue told him, though it's not quite clear how Wormie knew who Gimli's father was. When Gandalf introduced his companions on their arrival in Edoras, he only referred to Gimli as 'Gimli the Dwarf'. But Gimli himself gave his full name to Éomer when they first met (in
The Riders of Rohan), and Éomer may have mentioned it when he reported to the King (presumably in Wormtongue's presence).
(I don't think the Palantir had anything to do with it - unless you suppose its user interface included little pop-ups providing names and biographical information on people seen in the stone when you thought-clicked on them

.)