It’s tough to say. They have been “neutral” since 1499 when they left the Holy Roman Empire. In 1506, Pope Julius II hired the Swiss Guard because they were considered the best warriors in the world. They have been guarding the Vatican since.
Switzerland was overtaken by French revolutionaries in 1799. More of a civil war, but France did send troops to help stablize the region.
Once Napoleon was defeated, Switzerland was granted neutrality once again.
So, I guess the answer is technically never.
Never is the answer to the question of 'never been invaded' but the area of Switzerland has been invaded many times. Romans, various Germanic tribes, the Franks, Burgundians all had a piece of it at one time. Had they not been, what entity granted their neutrality? They have been a federal state since 1848 and not invaded. I suspect that their supposed invulnerability to outside force ties with some conspiracy you had in mind.
BTW, to what DMZ are you referring?