The cogs must be removed to replace spokes on the rear wheel. Or you may need to get a specific cog free of the rest to straighten out a bent tooth. Eventually, the teeth become worn and the entire cassette must be replaced. (Keeping your chain clean, and replacing it every 1000 miles, helps your cogs last longer.)
After inserting the freewheel tool into the lockring, use a wrench to turn it counter-clockwise to remove the lockring.
If you need to replace or work on a single cog, lift off the cogs down to the damaged cog, keeping everything else together.
Replace the cassette. The center of the cassette, and the smaller freestanding cogs, has square teeth that fit onto the shaft of the freewheel at one, and only one, position. Turn the cogs until these inner teeth line up with the slots on the freewheel shaft.