The source neutral wire on the receptacle is removed and spliced to the white running to the switch, and to a pigtail back to the receptacle neutral. At the switch, the neutral wire is needed to power some dimmer switches and is now required in most switch boxes.
This wiring diagram illustrates wiring a light switch to control an existing receptacle outlet. The source is at the receptacle and a switch loop is added to a new switch. The hot source wire is removed from the receptacle and spliced to the red wire running to the switch. The black wire to the switch connects to the hot on the receptacle.
This diagram is similar to the one above, but the switch comes before the new light in the circuit. New cable is run from the receptacle to the new switch location and from there to the light location. The switch may also be added in the the same box with the receptacle as in the diagrams at this link, where the two are installed in a double-gang electrical box.
Here a 2-way push-button switch is wired to a lamp with 2 bulbs. This diagram can be used to rewire an old push-button lamp with a new switch replacement. The hot wire from the cord is connected directly to the black wire on the switch and the neutral is spliced to the neutral contact on each bulb sockets. The red and blue wires from the switch are each connected to the hot contact on one of the bulb sockets.
New 2-wire cable is run from the receptacle to the new light fixture. At the receptacle the wires are removed and each one is spliced to the new cable and back to the receptacle with a pigtail splice. At the light fixture box the black wire connects to the hot terminal, the white connects to the neutral terminal and the ground to any metal grounding terminal on the fixture, outlet box, or both.
This diagram shows the wiring for a new receptacle added from a light switch. The switch must have an always-hot wire for the source and a neutral wire must be present for the return path. The hot source is spliced with a pigtail back to the switch, and to a new 2-wire cable running to the new outlet. The neutral is spliced in the switch box to both the existing light, and the cable to the new receptacle.
This page contains diagrams to add a new electrical outlet to an existing circuit. Arrangements are included to use an existing receptacle circuit or lights and switch circuits as the source for a new wall outlet.
Back at the source, the white neutral wire is spliced to the white from the fixture cable and to a pigtail, back to the receptacle neutral terminal. At the fixture the white connects to the neutral terminal on the light. The hot terminal on the light is connected to the red wire from the switch loop cable and the other end is connected to the top terminal on the switch.