If in doubt, always call your vet or the Animal Poison Line immediately.
Caffeine is a methylxanthine stimulant that is toxic to dogs in much smaller doses than humans. It overstimulates the heart and nervous system. Coffee grounds and tea bags are particularly concentrated and dangerous if chewed.
Emergency vet visit required. Bring information on what was consumed and how much.