I once departed from a controlled airport during PPL training when my headset failed just after reaching 500ft. ATC was in the middle of giving me instructions when it happened. I said to the instructor that my headset was malfunctioning, couldn't hear ATC, myself or my instructor. I asked if he could take over the radio while I kept the plane flying. He nodded, so I knew my mic was still working. After a turn into the direction I needed to go I went searching for the problem. Turned out to be a disconnected plug, the cable was wound around something and as I moved the plug was pulled out. It was a good learning experience, and I'm happy my initial reaction was to keep the plane flying, and also in the direction I needed to go