If it is relevant to a specific case. Not as a routine question.
That's the exact kind of doctor intimidation to which I was referring. Put the onus on the parent or patient instead of providing a justification for the question.
If the doctors really are more concerned about gun safety they wouldn't ask if there was a gun in the home. Kids can come across guns in any location. The better "safety" question would be, "do you know about gun safety; do you know what to do if you see a gun?" Then, provide the family with an Eddie Eagle pamphlet to take home. Even families who don't own guns should teach their kids about gun safety so they know what to do if they see one in their friend's house or on the street.