How you replace a lamp switch depends on several factors including the switch's location, and whether the socket is one piece of plastic or brass. The brass socket switch offers the greatest number of options when replacing the switch.
Ensure the problem is the switch
Before beginning the process of replacing the switch, try another bulb.
Unplug the lamp
Before working on a lamp, disconnect it from the power source. Remove the light bulb from the socket.
Remove the socket
Squeeze and pull the top of the lamp socket to remove it from its base. If it resists, use a screwdriver to pry it from the base. Once it is apart, use pliers to cut the wires.
Replace the switch
The switch is located in the socket and should now be loose. Remove it, and replace it with a new switch. Reattach the wires, and reassemble the socket. Replace the light bulb, and test the lamp.
Replace the socket
If replacing the switch does not repair the lamp, the socket is likely bad. Unplug the lamp, and remove the light bulb again. Remove the socket from its base. Loosen the set screw in the narrow part of the socket base. Turn the base to unscrew it from the lamp. Replace the old socket with a new one. Reassemble the lamp, and test again.