A male pilgrim in the state of ihrâm should not wear clothing that is sewn into a garment like a shirt or pants. (The ruling is not against stitching itself, like a hem on a towel, but against wearing a garment that is sewn or knit to close around the body).
This is certainly the case for conspicuous clothing like shirts, pants, and robes. It is less clear for clothing that is usually unseen or should be unseen, like underpants.
Wearing short pants under the pilgrim's waistcloth was the practice of a number of Companions.
1. al-`Alâ' b Habîb relates: "I saw `Ammâr b. Yâsir wearing short pants while he was on the plain of `Arafah." [Musannaf Ibn Abî Shaybah (6/34)]
2. `A'ishah relates that she used to instruct her male servants to wear short pants under their pilgrim's garb when they were in the state of ihrâm. [Musannaf Ibn Abî Shaybah (6/34)]
In consideration of the practice of some of the Companions, if a pilgrim has a need to wear underpants under his pilgrim's garb while he is in a state of ihrâm, either for medical reasons, or to avoid serious discomfort from chafing, or to avoid serious embarrassment, or to avert other problems, then he may do so without any objection. He does not have to expiate for it in any way.
In general, the rulings related to pilgrimage are geared towards the pilgrim's ease and facilitation.
And Allah knows best.