The ruling was one of several orders Beachley issued at the boy's sentencing Wednesday. The youth's name is not being published because he is a juvenile.
Beachley allowed the boy to live with his grandmother, placed him on indefinite probation through the Department of Juvenile Services and urged the department to closely watch the case. The boy could remain on probation until he is 21.
Beachley did not say when the boy could return to his parents' home.
Beachley ordered the boy to remain on home detention, monitored by an electronic anklet, for 30 days, and to undergo psychological and sex offender treatment.
Beachley ordered the parents to take parenting and sexual offense awareness classes.
The boy admitted in an Oct. 30 hearing to a fourth-degree sex offense involving sexual contact with a girl.
The girl was taken to Washington County Hospital in April after she miscarried a fetus, Kessell said at the October hearing. Hagerstown City Police investigators interviewed her, and she said she had sex with the boy.
Both Assistant Washington County State's Attorney Steven C. Kessell and the boy's defense lawyer, Margaret Teahan, agreed in October that the boy had sex with the girl once around Thanksgiving 2002.
No evidence linking that act to the pregnancy was presented in court.
Earlier this month, a 22-year-old Hagerstown man was charged in connection with a second pregnancy of the same girl, who since has turned 11. The girl no longer is pregnant.
When Beachley asked the boy if he had anything to say before he was sentenced, the boy replied, "I would like to go to my mom's house for Thanksgiving, but it's up to you."