If the kernel decides to do a context switch, it's in response to some event which caused the processor to enter kernel mode. This can be either a system call or an interrupt (which can be a timer interrupt or some other interrupts).
Whether the kernel is processing an interrupt or a system call, there are good and bad times to do a context switch. The kernel does what it wants to do, and then at the end of the processing it decides which user thread to schedule next. If it decides to schedule a thread which wasn't the last scheduled thread, it then does a context switch.
During critical parts of the processing, the kernel may disable interrupts. If an interrupt happens while the kernel is already active and doesn't have interrupts disabled, what usually happens is that the kernel does what needs to be done immediately (for example, read data from a peripheral), and adds an element to a queue to remember what needs to be done later. In Linux, these are called the “top half” and “bottom half” of interrupt processing; I don't think there's a standard term even though the concept is common. For example, if a network interrupt is triggered while the kernel in the middle of communicating with a disk, the kernel reads the network packet and stores it into a queue; then, when the disk I/O is finished (or can be paused), the kernel processes the network packet, and at this point it may decide to schedule a task that has received some input from the network.
In case there's any doubt, a timer is not required for a context switch. A context switch can happen any time a system call is in progress. The connection between timers and context switches is that if user code never makes any system call, and there is no system event (user input, networking, etc.) that causes an interrupt, the only way a context switch can happen is if a timer interrupt causes the kernel to wake up. And there are operating systems that only have non-preemptive multitasking; such kernels don't set a timer interrupt, and only do a context switch during a system call.