Do you play or stress the cpu during charging?
If yes it means, that when its charging your on completely different power plan (not power saving but balanced maybe), it means your cpu is not limited by power, so it works as fast as possible that's why it overheats, your cooler is not able to keep up, maybe due to dust inside the laptop.
Clean your laptop, change cpu thermal paste, use Laptop pad.