When the engine overheats when AC is not in use but overheating stops when AC is turned ON, there is likely a problem with the cooling fan system. Either one out of two fans is not working or the only fan is not working optimally.
Just as engines overheat, it is very possible for them to also be overcooled by their cooling systems or overcooled by the inrush of environmental air passing through the radiator.
There are salient causes of overheating that are hard to troubleshoot. One symptom is coolant bubbling even before engine attains operating temperature.
An incorrectly routed drive belt that makes the coolant pump to rotate in the opposite direction will cause overheating. This is possible when a belt of wrong size is used.
Transmission especially the automatics can overheat. The causes range from bad clutch, wrong fluid, overfilled or underfilled transmission and bad oil cooler.
Where there is no way to fix an overheating car on the spot, these are information needed to be able to drive an overheating car to a workshop or safe place.