The context of Hegseth's remark and the reactions of his co-hosts indicate he was joking.
On a Feb. 10, 2019 edition of "Fox & Friends Sunday," Pete Hegseth explained that his 2019 New Year's resolution was "say things on air that I say off air."
Following through on that promise, he told his co-hosts that he had not washed his hands in 10 years because "germs are not a real thing. I can't see them, therefore they are not real." His co-hosts laughed at the remark.
A Jan. 23, 2021 thread on Reddit brought the quote back to the surface two years later.
As reported by The Guardian, Hegseth largely walked back his comments, deriding the media for taking his words seriously:
On Twitter ..., Hegseth gave mixed messages. He claimed he had been joking and paraphrased the president in blaming the media for being so "self-righteous and angry". He also said he supported drinking from hosepipes and riding bikes without a helmet.
Germs are a real thing, even when you can't see them. This is one reason health organizations recommend washing your hands to prevent the spread of COVID-19 — a timely example of a real germ that would not be visible to Hegseth.
Because he did say those words, the quote is correctly attributed to Hegseth.