I would need more context to decide if it's offensive. Jillio gave two contexts that would change the offensiveness of the question. People who are okay with gay people ask casually if other people are gay all the time. It's just a question out of genuine curiosity.
On the other hand, coming from a homophobe it's an attempt at an insult. Saying "are you gay" when you're homophobic is basically a roundabout way of saying "so basically should I disapprove of you?" And the way it's said changes things too. "Hey, are you gay?" isn't the same as "What, are you,
GAY?" The latter is obviously meant to offend and provoke.
Not in the least. In fact, people ask me all the time and I have no problem answering anyone who I know are comfortable with my gender/sexuality. When someone who has displayed homophobic behavior asks me, I'm not offended so much as I don't feel comfortable coming out to them.
BTW I just wanted to thank you jillio for always taking the time to include transgender and bisexual people in the discussion of sexual minorities.