Was it just Gandalfs name for him? That would make more sense.

When naming Grima, Tolkien resorted to a special literary device -antonomasia. Therefore, Grima'snickname -Wormtongue -is a highly descriptive speaking name, and shows Grima's rotten nature.

But I don't recall it being mentioned as such in the book.

You're never even enough information about most of the characters in LoTR.