"Sir" is a proper form of address for female officers in the current real world military. At least it was up until 1993 when I got out.
The thing is, you'd usually call a female officer "Ma'am," because, you know, she's female.
Unless you were trying to subtly be a dick to her in a way that you couldn't get into trouble for.
Mr. Penis Drawing Pilot doesn't like Ex-O wife, ergo that was an appropriate use (plot-wise) of "Sir" to address her. Assuming that they're carrying over real world military regs/tradition.
IMO, it wasn't the show, the showrunners, or the writers being sexist. It was the character. By the end of the episode, he'd gained some respect for her, so it'll be interesting to see if he switches over to "Ma'am" or some more casual form of address.