Do you mean is it safe for the earthworms? I can't see any reason why not. They'll most likely be too far down to suffer if the coffee grounds are still hot. Coffee grounds and earth worms should decompose properly for your compost heap to be effective as well, if that's what you mean.
Yes, this should be perfectly safe. You can also add all sorts of other kitchen waste, as long as it is natural and organic. Many people use coffee grounds as a fertilizer.