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 is His slave and Messenger.
If the child is discerning, i.e. he is aware of a woman’s ʻawrah (what should be covered of the body), then the woman should wear the hijab in his presence, and he can not enter upon her without permission, as has been underlined by the scholars based on the verse: {...or children who are not yet aware of the private aspects of women...} [Quran 24:31]
Ibn Katheer wrote:
"The verse means that because they are so young they do not understand anything about women or their ʻawrah or their soft speech or their enticing ways of walking and moving. If a child is young and does not understand that, then there is nothing wrong with him entering upon women, but if he is an adolescent or approaching adolescence whereby he knows and understands these things and can make a distinction between who is beautiful and who is not, then he should not enter upon women without permission."
This differs from one child to another. Shaykh Ibn ʻUthaymeen wrote:
"Scholars said that {not aware of the private aspects of women} means that they are not physically interested in women and do not think about women in this way. Some children, when they reach ten years of age, start looking at women with lust; perhaps they sit with people who mostly talk about women, so they develop a sexual desire at an early age. Conversely, a child may be brought up in the company of people who are mainly concerned with learning, memorizing Quran, and similar interests, so this desire is not nurtured in him." [Sharh Riyaadh As-Saaliheen]
So if this boy seems innocent, then there is no harm in taking off your hijab before him. As for sleeping next to him in the same bed, you should avoid this in any case because this could be a means by which Satan would lure you into sin. Even if the boy is not tempted by a woman, he may be a source of temptation for her. Indeed, it is better to be safe than sorry.
Allaah knows best.