Method for controlling an oil-injected compressor device with at least one compressor element with an inlet for gas to be compressed and an outlet for compressed gas and with a variable speed controller, whereby the compressor device is provided with an oil circuit with an oil separator with an input that is connected to the outlet of the compressor element and an output to which a compressed gas consumer network can be connected, whereby this oil separator comprises a pressure vessel in which the oil separated from the compressed gas is received and from which oil can be guided to a cooler and can then be injected into the compressor element, whereby this cooler is cooled by a coolant that is guided through the cooler by means of a fan or pump, characterised in that a bypass pipe for oil is provided across the cooler, whereby the method consists of determining the temperature at the outlet of the compressor element and when this determined temperature is less than a preset value (T set), the following steps are taken successively: - first the fan or pump is switched off or its speed is decreased for as long as the temperature at the outlet is less than the preset value (T set) and the minimum speed of the fan or pump is not reached; - then the temperature at the outlet of the compressor element is determined again and, when this temperature at the outlet is still less than the preset value (T set), the oil is driven through the bypass pipe to the compressor element or an increasing proportion of the oil is driven through the bypass pipe to the compressor element for as long as the maximum quantity of oil has not been reached; - then, when the maximum quantity of oil that is driven through the bypass pipe to the compressor element is reached, the temperature at the outlet of the compressor element is determined again, and when this temperature at the outlet is less than the preset value (T set), the quantity of oil that is injected into the compressor element is reduced until the temperature at the outlet is at least equal to the preset value (T set) or the minimum quantity of oil is reached. - first the fan or pump is switched off or its speed is decreased for as long as the temperature at the outlet is less than the preset value (T set) and the minimum speed of the fan or pump is not reached; - then the temperature at the outlet of the compressor element is determined again and, when this temperature at the outlet is still less than the preset value (T set), the oil is driven through the bypass pipe to the compressor element or an increasing proportion of the oil is driven through the bypass pipe to the compressor element for as long as the maximum quantity of oil has not been reached; - then, when the maximum quantity of oil that is driven through the bypass pipe to the compressor element is reached, the temperature at the outlet of the compressor element is determined again, and when this temperature at the outlet is less than the preset value (T set), the quantity of oil that is injected into the compressor element is reduced until the temperature at the outlet is at least equal to the preset value (T set) or the minimum quantity of oil is reached.