I found this article from Doctors For Responsible Gun Ownership discussing what you, as a patient, should do if a doctor asks about guns in your house.
Should a medical professional ask about guns? Yes, but only in a few limited scenarios. The big one is if they believe the patient is imminent danger of causing harm to him/herself or others.
As a routine question? Nope. Any more than they should ask how much you drive (which is a bigger danger).
The article also specifies to find out who is actually asking the question, the doc or the healthcare system. Having worked in healthcare on the administrative side for more than a decade, I’ve seen a lot of stupid stuff foisted on the front line staff because someone in the upper echelons thought “it’s a good idea.” I’m not going to take actions against a doctor who’s being forced to ask questions because of some bureaucrat.
Fortunately, my doctor has not asked. I’d like to think he respects me enough not to pry into affairs outside his scope of practice.