ob ... gilt
is a relative subordinate clause (relativer Nebensatz bzw. RelativsatzRelativsatz/Nebensatz). It relates to the surrounding sentence: it further explains which Frage
the rest of the sentence refers to.
As such, it needs to be surrounded by commas. See Duden D118 and §74 (on page 81) of the official rules (released 2018, PDF) (online version) based on the 2016 recommendations of the council for german spelling. Both sources are in german.
Subordinate clauses can be identified easily: if you drop out everything between the commas, it should still read as a valid sentence (that may provide less information though). Die Frage darf man nur stellen, wenn ...
is valid, hence you need commas when inserting a subordinate clause.
Another example: Die Frage darf man, selbst als Geschäftsführer, nur stellen, wenn ...
This subordinate clause indicates that even a CEO may only ask this question, when ... This construct sort of indicates that the sentence is about a very special or tricky question (which not even a CEO may simply ask), even though the subordinate clause is not placed next to Frage
.