Switching involves moving packets between devices on the same network. Conversely, routing involves moving packets between different networks.
Switches operate at layer 2 of the OSI Model.
A router is able to determine where to send a packet using the Network ID within the Network layer header.