If I am in the line at Dunkin + notice that the car in front of me left their gas cap open, is it ok to tap on her window to let her know?
With these types of situations, I like to look at it this way: would I appreciate it if a stranger let me know? If the answer is yes, I let how I feel about the scenario inform how I approach the person.
If it's late at night, and sort of spooky out, don't approach in a way that might startle. Even if you flash the headlights that might be enough to get them to look closely at their car and see the issue, whether it's a burnt-out taillight or the gas cover left open. If it's the middle of the day, and you're in public (like in the Dunkin drive-through), I think you're fine to approach and let them know. Just be sure to step back from the car so you don't crowd the person in the driver's seat.
Funny story: one of my best friends growing up had a Chevy Corsica with a gas cap that was stuck open. There was no way that cap was closing... it was stuck open forever. Quite a few people honked or otherwise notified her, which was nice of them. :)