Another examples of Codies' fine coding at work...
It could be worse though. I've never run out of fuel, mostly because I was made aware of this very early in the games life. There are a few rules of thumb that you can use to help keep your car running.
1. Err on the side of caution.
The only time fuel is going to make a major difference pace wise between two cars is if you and your opponent are matching each other perfectly time for time. Beyond that, the small amount you stand to gain from stretching the "optimal" phase is nothing compared to what you stand to lose from running out.
Any time you flick the fuel up to rich, you really need to be checking all the time, especially for longer races. Once you hit optimal, you have about a two to three lap window. If you stay within this, changing the mix back to standard should be enough to keep you in the game. Four to five laps over means you will need to compensate by running lean mix for a few laps. Depending on many laps remain, going much beyond five laps is tempting fate. Better to play it safe.
2. Conserve when you can.
Sure, the engineer tells you to go lean during a safety car phase, but that's not the only time you can save a bit of fuel. If you're in a really tight battle and don't want to risk running out, adjust the mix when you're pitting in or going into a slow section of the track. This can give you a bit of a safety net in case you overextend your rich mix phase.
3. Be reasonable with your gaps.
I've nearly fallen victim to this a few times. After I pass the guy, I leave the fuel up because I want to build a gap. Thing is, if the other guy is a clean racer, you can stand to turn the fuel down to standard. Typically when the lead car is being caught he'll up his mix to maintain the gap. Even if you pass him and then slow down, he'll still leave the fuel up to try and repass as quickly as possible. By driving defensively and keeping him behind, you'll keep him burning much more fuel. Playing mind games like this not only saves you fuel, but may run your opponent out.