The neutral and ground wires for the circuit are connected to a bar along the side of the service panel box. The neutral and grounding bars in the box may be separate or, in the case of older service panels, the same bar may be used for both purposes.
The white wire on the switch loop is used to carry current from the source to the switch and it is marked with black tape or paint to label it as hot. The black on the switch loop runs from the top switch terminal to the top half of the receptacle. With this arrangement the top half of the duplex is controlled with the switch and the bottom half is always hot.
This page contains wiring diagrams for adding a new light fixture using an existing receptacle as the source. Diagrams include adding a light from a switched receptacle and tapping an always-hot outlet. Different wiring arrangements are included to allow for either the light or the switch to come first in the circuit.
This diagram illustrates the arrangement for a 20 amp double receptacle circuit with a shared neutral wire. This arrangement is typically used in a kitchen where two appliance circuits are needed in close proximity to each other.