Why does the cooling fan only turn on when engaging AC?

Check the fan relay, if it is good then replace the coolant temperature sensor, the AC circuit is separate but it does verify that the fan works.