It's a joke, nothing more. It combines a bit of ribbing the captain, common enough in films of the time such as the raw egg trick in Spartacus where Tony Curtis sets up a magic trick then pulls a switch so Kirk Douglas splatters a raw egg on himself. It also is a dig at the Nazis themselves as we, the audience, know Kirk is nothing like the Nazis. That, too, is done frequently in comedies and dramas of the period. It is also was way, in story, for Spock to ride Kirk over his own commenting on the Gestapo uniform being the more attractive uniform.
KIRK: Yes, it's a shame yours isn't as attractive as mine. Gestapo, I believe.
SPOCK: Quite correct. You should make a very convincing Nazi.
God, spare us from the humorless.