It's called a flare. Typically, oil and gas facilities use them to get rid of unwanted natural gas that cannot be effectively captured and sold. (Either due to lack of export pipeline or for a safety blow-down to depressurize equipment filled with gas during an emergency.)
Surprisingly, burning the gas makes it safer and more environmentally friendly to vent into the air. Oil is usually not burned because it's easier to capture and ship to land for sale. Normal well drilling does not require flaring. Only very small quantities of natural gas should be brought to surface during drilling. That small volume is typically "cold-vented" instead.
Typically, flares are used by facilities that are flowing oil to surface and separating oil from gas. Even when no gas needs to be burned off, the flare should be left burning 24/7 with a pilot light so it can be used in an emergency.