Operation: Broken Feather - S1-E15
Adam Sandler: This is terrible, you don't know what you're doing.
Jake Peralta: Adam Sandler?
Adam Sandler: Yeah, that's right. I collect antiquities. I'm a serious person. I'm writing a movie right now, about the Russian revolution.
Jake Peralta: Oh, really? Who does Kevin James play in it?
Adam Sandler: Ha ha. It's a serious movie...Trotsky.
Jake Peralta: Ah, there it is.
Adam Sandler: But he's got a wife who never wears a bra. [To the guy next to him] I think you're going to like it.
Jake Peralta: Thanks for dressing up, by the way.
Answer: In reality, the Commissioner is a civilian administrator, appointed by the mayor of New York City. He (as of this writing, the role has always been filled by a man; the show gets that part right) is usually someone who has risen through the ranks of the NYPD, but upon becoming Commissioner, is no longer a sworn member of the force (the highest sworn rank is that of Chief). Since Commissioners are appointed, technically anyone can serve in the position, including Deputy Commissioners (who are appointed, in turn, by the Commissioner himself).
Update: On 1 January 2022, Keechant Sewell became the first ever female commissioner of the NYPD.