For example, in a turbofan engine the air is taken from the ambient air outside the engine or is it taken from the compressed air from one of the compressor stages ?
Kerosene burning high altitude airplanes generally use fuel as the oil cooling medium, because you need to heat the fuel anyway due to the low operating temperatures at altitude. It limits ice formation in the fuel controller, and improves atomization. Sometimes it's just called a fuel heater, not an oil cooler.
If not, then you would use an air/oil heat exchanger, but you still need to heat the fuel, in which case you would have to use bleed air or an electric heater to heat that.
So much simpler to use the hot oil in the engine to warm the fuel. In no case would you use engine bleed, which is hot, to cool engine oil. If it's not an oil/fuel heat exchanger, a stand alone oil cooler will take ambient air ducted to it.