When one is praying the silent 'Amidah, and one hears the Qaddish or Qedusha and the like, one should not answer. Instead, one should stop reading the 'Amidah and concentrate on what the Shaliyah Sibbur (Hazzan) is saying. In this way, it is considered that one answered the Qaddish and Qedusha and fulfilled one's obligation. Despite this, it is not considered to be an interruption in the reading of the 'Amidah.
One needs to be silent till "Barukh Kebod" in the Qedusha, or up to "Be'alma" in the Qaddish. After that, one may continue one's prayer as usual. All this applies up to the portion of "Elokai Nesor", at the end of the 'Amidah. After that the rules are different.
All this assumes that one can hear the Hazzan. If, however, one is far away from him and can't really hear him, one does not stop, but continues reading as usual.
(See Ben Ish Hai, 1st year, Mishpatim, Oth 5. Qisur Shulhan 'Arukh 18:14)
Kitzur Shulchan Aruch, Ben Ish Chai, Answering Kaddish or Kedusha during silent Shmonei Esreh, the Lachash, Lahash