Sir unaccompanied by a comma can bug me, too—but there’s a reason we sometimes see that. Your examples are direct addresses, which the “rules” say are to be set off by commas: “I told you not to do that, Anne.” But the rule gets fuzzy when it comes to the word sir. It turns out yes sir can, in fact, go without a comma when it’s used almost as a single word, as in “Yes sir! I will.” This is covered in entry 5.47 of The Chicago Manual of Style (14th ed.), which most fiction publishers use. In a nod to the fuzziness of usage and punctuation, each publisher creates its own “house style guide” to codify its preferences. (Yes, the guides can be word-specific.) Copy editor sensibility then factors in. She may decide on “Yes sir,” she said to follow house style (she’ll have a guide for each house she works with), or she may sense “single word” usage, or she may want a clean look for the text itself. After all, “Yes, sir,” she said has a lot of punctuation for a sentence with so few words. Does punctuation fussiness serve that book? Good copy editors know the rules but also consider the flavor of each project.