How do you insert a complete sentence quote into the middle of a sentence before a comma?

There are several alternatives if you want to retain the quotation marks and question mark, which I list here in shortened form:

  1. Before you walk into a room and ask, "Who died?", you should ...
  2. Before you walk into a room and ask "Who died?", you should ...
  3. Before you walk into a room and ask, "Who died?" you should ...
  4. Before you walk into a room and ask "Who died?" you should ...

The basic form is "Before you do X, you should do Y," which means that the comma before you is necessary to separate the clauses and (3) and (4) can be rejected.

Version 1 has a comma before the reported speech; that's standard form. Here, though, it is probably not necessary because the "Who died?" is so closely tied to the first half of the sentence that it doesn't need to be set off from it. There is also the possibility that the first comma could be interpreted as the end of the first clause [whereas it is in fact the second comma], or that the quotation between the two commas is a parenthetical insertion.

I prefer version 2.

If the quotation ended in a full stop and not a different mark, then it would suffice to omit it altogether and simply use the clause-separator:

Before you walk into a room and say "You look sad", you should ...


It is worth considering a further alternative:

Before you walk into a room and ask who died, you should ...

This doesn't use reported direct speech, it reports the activity and describes the situation. It's left to the reader to imagine the scene and the intonation. Do you really need to put that in the writing? Perhaps this is straying into the territory of writing advice.