Shaving the head (الحلق) is more virtuous than trimming (التقصير) for men after both الحج and العمرة. النبي (صلى الله عليه وسلم) made الدعاء three times for those who shave their heads and only once for those who trim, indicating the superiority of shaving. He said: 'O Allah, forgive those who shave their heads,' and the companions said: 'And those who trim, O Messenger of Allah?' He said: 'O Allah, forgive those who shave their heads.' They repeated the question three times, and on the third occasion he added: 'And those who trim.'
الشيخ ابن باز stated that while both shaving and trimming are valid ways to exit the state of الإحرام, shaving is preferred and carries greater reward based on النبي's triple الدعاء. He مستحب that men shave their heads after الحج and after العمرة. However, if a man is performing الحج tamattu' (العمرة followed by الحج), it is better for him to trim after the العمرة and save the shaving for after the الحج rites on the Day of Sacrifice, so that he has hair to shave during the greater rite.
Sheikh الألباني confirmed the superiority of shaving and noted that النبي himself shaved his head during the Farewell الحج. He distributed his hair among the companions, who treasured it. For women, shaving the head is not جائز — they only trim a fingertip's length from the ends of their hair. This applies to women after both الحج and العمرة without exception.