A telephone switch (or in the UK, telephone exchange) is a device for routing calls from one telephone to another, generally as part of the public switched telephone network). Usually a complex machine (or series of them) in a central exchange. They work by connecting two or more circuits together, each circuit being connected to a subscriber telephone, according to a dialed telephone number.
While, traditionally, telephone switches connected physical circuits (e.g., wire pairs), modern telephone switches use digital time division switching. In other words, each voice channel is represented by a time slot rather than a physical wire pair. In order to connect two voice channels (say A and B) together, the telephone switch transfers the information in the time slot assigned to A to the time slot assigned to B, and vice versa.
Telephone switches are usually owned and operated by a telephone service provider and located in their premises, but sometimes individual businesses or private commercial buildings will house their own switch (which may well be owned and operated by a telephone service provider still).
Switches are used in both local central offices and in long distance centers.