Lux ferens, no, it is cetainly not mandatory to switch on a transponder where carried.
It is only mandatory to have a serviceable SSR outside regulated airspace below FL100 if you are operating under IFR. (This is a bit of a simplification as there are other rules in the Jockistani TMA). Hence Golf-Alpha-Good-Morning-All-I'm a PA28-err... can quite happily operate under VFR without talking or squawking. Which is bliss!
Mark you, for sport you can always go and find one of those corner-cutting airliners in Class G airspace, sneak up on it with the IFF at standby and then switch it on at close range and watch the chaos as the TCAS TA/RA is responded to... No, on second thoughts, please don't