Diagnosing these kind of things can be tricky, so be ready to invest some significant time to root-cause them. There are as many opinions about optimization as there are computers on the internet, so I'm going to do my best to hit the high points.
The first step is usually pinpointing why you're having issues. Are you having CPU, disk, or network spikes that correspond with your in-game latency? Using Process Explorer or Performance Monitor can help you track various trends going on in your machine (and can help you identify what is causing it to an extent):
Tracking CPU and Memory usage per process
Here's some more general advice. I don't know if all of this is going to apply to your specific situation, but it can't help to be more informed.
Clearly you want to minimize the number of processes running in the background while you game. Browsers, for instance, are generally refreshing and redrawing pages even if they're in the background. They're a key culprit in many cases. Flash animations on background pages eat your CPU without usually performing anything useful. If you don't want to shut down your browser completely, you might consider installing a flash or ad blocker, which at least cuts down on the useless churn the browser is doing.
Antivirus gets a bad rap, and there's a chance if you're playing a game that it is running in the background. I would suggest ditching the "name brands" in firewall/antivirus software (Symantec and McAfee) as they are known resource hogs. Microsoft Security Essentials is generally good enough for most people, it's free, and it tends to be lighter in terms of resource usage.
The flipside of antivirus software is that sometimes you can get infected with viruses and spyware that consume system resources without your knowledge. Make sure your antivirus is up to date and running, and that you've scanned for spyware recently with a program like Malwarebytes or Spybot S&D.
Many software packages install background tasks that run constantly as well. If you don't need this functionality, it's good to turn it off. Video drivers and printer drivers are surprisingly some of the worst. You can use MSConfig to examine the background processes that start with Windows, and decide if they're worth keeping. Most of the time your drivers will work just as well without the constant background task running, but make sure you test thoroughly to make sure there aren't any issues.
Windows Update is another background process that runs frequently and can consume CPU and network bandwidth if you let it. As long as you monitor it closely, it should be safe to set it to a more manual mode so that Windows doesn't choose the best time to download and apply patches for you.
Windows Services provide useful functionality to your computer, but not all of them are required. There are guides on the web about what services provide what features, so you can decide if you want to selectively disable them, and perhaps regain some lost resources.
Sometimes bad drivers (outdated or just buggy) can cause issues in games. Try looking for the most updated drivers you can find.