You don't put grease on gears, you use oil on the chain.
NEVER use WD-40. Use Tri-flow, or mechanical oil, or Phil Tenacious oil or an equivalent. Try and keep it in the chain bushings, then wipe off the excess. You're trying to keep dirt from sticking to your chain.
Clean grease and dirt off the cassette itself.