Although I agree with you that it is not meant to be taking as a comedy episode overall. I felt that line was not meant to be taken seriously. There is other comedy in the episode. Such as when Kirk is standing on Spock (or is it the other way around, I can't remember) and when Bones enters half dressed. The episode isn't Hogan's Heroes for sure but it isn't completely super serious either.