The thing to remember is that Janice Lester was psychotic. It's easy enough to interpret her belief that women weren't allowed in command as a paranoid delusion, a rationalization for her own inability to measure up. Of course that's not how Roddenberry apparently intended it; it's pretty clear that he intended the episode to say "It's crazy for women to aspire to do men's jobs and they should be happy in their own separate societal roles that are valuable in their own way." But given Lester's irrationality, it's easy to treat her as an unreliable narrator and dismiss her assertions. Kirk appearing to accept her premise could simply mean that he was humoring her delusions.
In the novels and comics, there are female captains serving contemporaneously with the events of TOS. The Vanguard
novels feature Captain Atish Khatami of the Endeavour
and Captain Hallie Gannon of the Bombay
. (Also Captain Rana Desai, but she's a starbase JAG officer rather than a starship commander.) John Byrne's IDW comics, in a different continuity, feature Pike's Number One as a commodore in command of the Yorktown
toward the end of Kirk's 5-year mission.