(This material is not included in the 2020 edition.)
I’ve recently come across a couple of authors who are doing this:
Of course, I am.
They’re putting a comma after “of course” whenever it appears. Possibly, they’re following the advice of their word processor in doing so (often a bad idea).
As often happens, this tingled my spidey-sense that something was wrong, and then I had to figure out what the rule was, based on introspection.
This is a rare case of grammar that operates across sentence boundaries. If the sentence that begins with “of course” is an answer to another sentence, which is (or can be rephrased as) a question about whether something is or is not the case, it doesn’t take the comma:
Are you Henrietta Wibsley?
Of course I am.
The rule operates not only with the “to be” verb, as in the example I just gave, but also with have, do, and the modal verbs (will/would, can/could, may/might, must, shall/should), and where the reply restates the sentence it’s responding to:
Does Henrietta know karate?
Of course she does.
Does Henrietta know karate?
Of course she knows karate.
Has Henrietta been into space?
Of course she has.
Will Henrietta be coming?
Of course she will.
Can Henrietta fly a rocket?
Of course she can.
May I sit here?
Of course you may.
Must I salute the general?
Of course you must.
And so on.
The first statement doesn’t have to be phrased as a question:
Henrietta can tango.
Of course she can.
There’s an implied “can’t she?” at the end of the statement.
The rule is actually even simpler than I’ve stated it above. In all of these cases, the answer could simply be, “Of course.” The rest of the sentence is restating or rephrasing part of the question (or original statement). If the answer could simply be given as “of course,” don’t use a comma.
Nor does the phrase have to be “of course”; it can be any equivalent, from “indubitably” to “darn tootin'”, from “you bet” to “naturally”. I like to think of the late great Alan Rickman in Harry Potter and the Order of the Phoenix responding with heavy sarcasm to Dolores Umbridge’s rhetorical question about his application to be Defense Against the Dark Arts teacher:
Umbridge: But you were unsuccessful?
Snape: Obviously.
You could expand his answer to “Obviously I was”. There’s no comma.
So do you ever use a comma with “of course” and its equivalents? Certainly you do.
Of course, if you’re adding new information that’s not a response to the previous sentence, you do need a comma.
You can put the phrase at the end of the sentence that gives new information, of course.
This means, of course, that you can have two versions of the sentence punctuation that are both correct, depending on the sentence that precedes them:
Henrietta is an aardvark. Of course, I knew that.
Did I know that Henrietta was an aardvark? Of course I knew that.
Similarly to the coordinate comma rule, another test for which version applies is whether you can move “of course” to the end without it seeming weird:
Henrietta is an aardvark. I knew that, of course.
Did I know that Henrietta was an aardvark? I knew that of course.
(Credit to Marie Brennan for pointing out that last test.)
For fiction writing, bear in mind also that the phrase “of course” carries implications about the character who says it and their attitude. It’s often used to add authority to a pronouncement that isn’t really as certain as the speaker is making out:
Of course, we know exactly why you were there that night.
It’s frequently used by academics in this way. There’s a bit of unconscious arrogance (and/or conscious bluffing) woven into the usage.
In the non-comma version, responding to a question, it can come across as snippy, carrying the implication “you didn’t even need to ask that”, or “that’s so characteristic for you”:
May I sit here?
Of course you may.
I know the answer.
Of course you do.
It’s all in the tone and the relationship, though. “Of course you may sit here” could be kind reassurance to someone lacking in confidence–but it still implies condescension, a superior talking to an inferior.
Some of the equivalent phrases don’t necessarily carry this implication. If you ask, “Do you want pizza?” and I respond “Damn straight I do,” that’s more about being emphatic than being condescending. I’m implying “I am very hungry, and pizza is exactly what I want; thanks for suggesting it.”
So, keep in mind the implications of this kind of back-and-forth for the relationships between your characters. But also keep in mind these simple rules:
If the sentence is a response to a previous sentence, and could be phrased as simply “of course,” don’t use a comma after “of course” (or its equivalents).
If the sentence provides new information that is not a restatement of the previous sentence, use a comma after “of course” at the beginning of the sentence, or before “of course” at the end of the sentence.