Without getting too complicated, in this series of Icom radios, the mic is in series with the PTT switch. The small current flowing through the mic when the button is pressed is sensed by the radio and it goes over to transmit. Therefore if you press the internal PTT on the side of the radio, it is wired in series with the internal mic, so the mic works. If you press an external PTT in series with the external mic in the headset, then that mic works. So the choice of which mic works depends on which PTT is pressed, not whether a headset has been plugged in or not.
Beware though, different series of Icom radios use different PTT arrangements.