Earthworms are part of the growth machine that operates unseen in your lawn. If you eradicate the earthworms, you upset natural processes like nitrogen fixation and conditioning actions such as aeration. If you feel you have an earthworm problem, you can do something about it -- but never use a pesticide. Using a pesticide to get rid of earthworms in your lawn is akin to using a flamethrower to light a candle -- you'll light the candle, but you'll incinerate it along with your house. If you think there are just too many, you can rid your lawn of a significant number of earthworms by simply making it inhospitable to them.
Sweep away the dry worm casts during spring and summer, and rake and remove grass clippings. Removing the organic matter lowers the nitrogen in your lawn, and it also decreases earthworm activity. You can add the worm casts to the compost.
Rake the thatch buildup on your lawn using a dethatching rake; discard it or add it to the compost. Earthworms feed heavily on thatch, and removing it makes your lawn less hospitable to them. It also improves your lawn's aeration and sets it up for acidification.
Check your soil's pH. If necessary, amend it to under 6.0 using ammonium sulfate. Earthworms don't deal with acidic soil well, and don't inhabit soils with a 4.5 pH or lower. Water the lawn after applying the sulfur amendment if you're experiencing a dry spell or the temperature is 90 degrees Fahrenheit or above.
Run a heavy lawn roller across your lawn in perpendicular directions if earthworms have created a bumpy surface, and then aerate with a core cultivator. Compacting and aerating your lawn will correct the unevenness earthworms create with their burrows.