Welcome to the forum. I think you meant to ask the question When should I offset someone's name with commas? Question phrases begin with a question word which is followed by the verb, then the subject. The phrase When to offset someone's name is an affirmative statement, not a question.
Many writers and editors would omit them nowadays, as commas are used less than they used to be, but the commas in your sentence are fine.