Mine was caused by a secondary air pump relay. The dealer told me it was the pump itself. I tested the pump, checked the fuse, and then determined that it was the relay. I changed it 2 months ago and the light went off and hasn't come back on.
If you think its the gas, just go get a bottle of octane booster and take your car for a highway trip and beat on it for a while.
2004 525i AUTO, STAGGERED 20" BEYERN RAPP WHEELS
160k+ MILES AND STILL CRANKS UP LIKE THE DAY I BOUGHT HER