They set the PIT to generate clock interrupts every, say, 10 ms, and switch tasks whenever a clock interrupt occurs. The way they pick the task is where it gets interesting. The simplest method is just to have a queue of tasks and then go through them in order. This algorithm is called round robin. There are other, more complex algorithms that allow prioritising but still ensure that all processes get to run. One method is to have several queues where each process in each queue has the same priority, but each queue has a different one. Then you do a prioritising scheduling algorithm to select the queue and then round robin (select the next one) on the queue itself. Whenever there's nothing to do, you just switch to a default process that does nothing, to waste the CPU's time (on Windows this is what the System Idle Process does; on Linux, the init process does the job).
As chris has said, there's lots of different ways to do this, and each platform does it differently. This book does a nice job of explaining it, and describes each major platform's way. It even provides some code out of the Linux kernel.