Get (and Use) an ESD Wrist Strap
The best way to avoid zapping the components inside the computer case is to wear an ESD wrist strap. One end slips on your wrist and the other connects to the case’s chassis (the metal frame) with an alligator clip. This device channels static electricity, or grounds you so to speak, so you can’t damage the computer or components. ESD wrist straps are extremely inexpensive and are available online or at any computer store.
If you're on an Assembly Line, use an Antistatic Mat
In addition to ESD wrist straps, antistatic mats are available. They work basically the same way but are more expensive and less convenient. The mat absorbs any electricity you may be carrying or the line may be carrying. On assembly lines, workers often stand on these mats, work on mats, and wear antistatic wrist straps.
Ground Yourself Manually
If you do not have access to an antistatic wrist strap or a mat, you can ground yourself properly by placing one hand on the power supply and keeping it there during the entire process. Unfortunately, this leaves only one hand for working, and you may be tempted to remove your hand, if just for a second, to do something else.
Leave the Computer Plugged In
Finally, you can ground yourself by leaving the computer plugged into the wall (turned off, of course) and by touching the metal chassis before touching any computer part inside. When you touch the computer chassis while the computer is plugged in, any static buildup you might have yourself is discharged because the electrical circuit is grounded by the outlet.I'd rather not be the one to suggest you opt for this technique though, because working with any plugged-in electrical component produces risks not associated with one that isn’t, and you could be shocked, among other issues. Only use this option if it's a last resort, and again, I don't advocate it.