Being someone who likes to build and overclock computers, I can name a few (very extreme) cases where this could potentially happen. (I emphasize potentially because such conditions are somewhat unrealistic in most machines today.)
The first example is a BIOS flash. Some motherboards allow you to flash (modify) the BIOS via software from within the OS. This opens a backdoor for malware to flash the BIOS to something that will damage the processor. (for example, increase the voltage to 2V - and BOOM!!!)
In a second case, some motherboard provide overclocking tools that allow you to change CPU settings from within the OS. If a virus takes over that - then like in the first example, set your CPU to settings that are damaging and fry it.
In a third example (possibly the most realistic ones) are the stress-tests and intensive applications. For example, most laptops today aren't designed to run numerical code for very long durations and may overheat. Although hardware temperature sensors will usually shutdown a machine that has overheated to a certain point, the thresholds tend to be very high - and it is not safe to sustain a CPU at a temperature just below the safety shutdown threshold.
An example of some code that has the potential to overheat a CPU is my answer to this micro-optimization question: How do I achieve the theoretical maximum of 4 FLOPs per cycle?