All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Muslim scholars held different opinions regarding the permissibility of ear piercing for young boys. Some considered it prohibited and considered it a kind of impermissible torture. Perhaps the most valid opinion on this issue is that ear piercing is permissible for girls apart from boys. Ibn Muflih said:
Ear piercing is permissible for girls for beautification purposes and is disliked for boys. Imaam Ahmad stated in a tradition reported by Muhanna "It is disliked for young boys, but not for girls." Muhanna asked, "Who considered it disliked?" He, may Allaah may have mercy upon him, replied, "Jareer ibn ‘Uthman." Ibn Al-Jawzi also confirmed in Minhaj Al-Qasideen and other books that ear piercing is impermissible for girls as it causes a painful wound, suggesting that necklaces and bracelets are sufficient for adornment purposes. [Al-Adab Ash-Shar‘iyyah]
As for what you have mentioned about the venerated imam of Ahl As-Sunnah, Ibn Hanbal that he used to wear earrings when he was a young boy and the aforementioned story, we have not come across any tradition in this regard and could not find a trustworthy narrator whose narration and reliability are accepted as proof of such a story. Anyway, this report is highly unlikely.
Allaah Knows best.