Warning, large amount of explanation, if you simply are looking for the answer, skip to the next bolded area.
When asking such a question, think about all the possible outcomes and parties involved, and try to find a middle ground that has the least potential to offend all parties the least. So in this case, it's a pretty polar issue, you have typical gendered people, such as males that identify as males and females that identify as females, and atypical gendered people, such as those having undergone sex changes, those who simply prefer to be refered to as the opposite gender, those that are both male and female and so on.
Regarding typical gendered people, you have three distinct categories in regards to how they might take this question. You have those who are comfortable with their own gender and are relatively passive or supportive of gender issues. These ones are unlikely to be offended no matter how you word your question. You also have those who are not comfortable with their own gender, whether it be perhaps a male with a somewhat feminine voice or appearance, a masculine looking female or such. These ones are likely to be your toughest cookie, as it is entirely possible that no matter how well you word your question, it's entirely possible they might still be offended. This is the kind of people Kristina's question seems to be worded to specifically try and not offend, with the combination of apology and statement of obviousness. Thirdly, there are those who are comfortable with their own gender, but are against gender issues. These ones aren't likely to be offended, but may comment that such questions are ridiculous or something to similar effect.
On the other hand, there are two distinct categories I can think of in regards to how atypical gendered people may take this question. The first is atypical gendered people who understand that gender issues are an ongoing debate, and that not everyone is comfortable with atypical gendered people yet. These ones are similar to the first category of typical gendered people where they will be difficult to offend. Secondly, there are atypical gendered people who are relatively not as passive about gender issues. This category is likely to be offended by any possible cynicism or potentially negatively seen opinion about having to ask such a question.
Breaking down the possible aspects of a question, we can fairly well evaluate which category has potential in general to be offended by each aspect. Firstly we have:
"What is your gender?"
The second category of typical gendered people has a relatively high potential of being offended by this question, but this depends on how many previous questions there were and how they were worded. If there were 10-20 or so different, yet similar personal questions asked prior, it's entirely possible they may understand that you're simply going through a checklist style sheet and not be offended at all.
"Are you male or female?"
This is a wording of the question that conflicts with potentially three categories. Both categories of atypical gendered people may be offended by this, or simply unable to answer in the expected response, because, as mentioned prior, there are cases where the person doesn't necessarily fall into either category. Black and white question wording for a potentially gray answer, no matter the rarity of a gray answer should usually be avoided. In addition, this still doesn't avoid the issue of the previous question regarding the second category of typical gendered people.
"I'm sorry, but company policy dictates that we ask this question: What is your gender?"
A person who lies in the second category of atypical gender has the possibility of being offended by this, due to you apologizing for having to ask what, to them is a perfectly reasonable question. This does avoid potential issue with any typical gendered person, but it does raise another seperate issue of apologizing for carrying out a company's policy, which is generally frowned upon.
"As obvious as it may seem, company policy dictates that we ask what your gender is."
Generally, the term 'obvious' should be avoided whenever possible while asking a question. It is typically considered just as polite, if not moreso to ask a question without the word obvious than with. The word obvious implies an assumption of knowledge on one party's part or another, which is never a good thing to assume, and can lead to offending people with relative ease. The likely offended party in this case would be those in the second category of atypically gendered people.
If you simply want the answer and not the full explanation, skip to here.
Looking at all the possibilities and outcomes, there are several correct solutions, depending on you as a questioner and the format of the application questioning itself. If the application asks a large list of questions, it is relatively safe to simply ask the question in the same format as all previous questions, likely by asking: What is your gender? If you'd like, you can try and avoid more by phrasing the question like: What is your self-identified gender?, as this question makes no assumptions, nor does it sound like a question that could be easily assumed.
If you as a questioner still feel uncomfortable about asking such a question, or it is one of only a few questions, it would probably be best to preface the whole questionaire with a statement along the lines of. Company policy dictates that I have to ask you a number of certain questions to ensure our records are correct. and then simply asking What is your gender? when you get to that point in the questionaire. The benefit of this is that it absolves you of any responsibility of the questions asked, but doesn't necessarily show any disagreement with the company's policy. In addition, this avoids raising any potential issue with one specific question.
Apologies for the length of the answer, I know it should be a relatively simple issue, but with the wide variety of opinions in today's society, I feel that it's best to break down such an issue to its core. Hopefully this answers your question reasonably enough.