Then comes the part where Karna loses the Kavach Kundal and earns the Indrastra. As mentioned earlier, Karna had the kavach kundal which made him virtually immortal. Knowing that Karan would eventually encounter Arjun in the war, Krishna wanted to take these powers away from Karna. So he asked Indra to come disguised as a beggar and ask for the kavach and kundal. On hearing about the Gods conspiring against his son, Surya(Karna's father) appeared in his dream and warned him about Indra coming as a beggar to take his protection. However charity was Karna's very nature.So despite the warning, and knowing fully well that giving them up would lead to his death, he willingly gave them up when Indra came to ask for them . Impressed by his generosity, Indra gave him the Indrastra, which could kill anyone it hit, but could only be used once.
Source: How Did Karna Die