For my two cents, the earlier the better. Dogs are like kids; they learn a lot more than we think, earlier than we think. And the longer you wait, the more you have to undo the bad habits; in this case, leaving the yard.
I brought my Brit Lab home at 49 days. On day 50 I took her out, grabbed the newspaper, put it near her mouth and said fetch. All the time acting excited but encouraging. On day 51, took her out to get the paper, said fetch, and put in in her mouth, said fetch and ran back to the door. Day 52, opened the door, said fetch the paper, and she ran out, grabbed it, brought it back and dropped it. I haven’t had to get the paper in a year, which is nice in snow and rain. She became an overnight retrieving nut by starting young and making it fun.
Next tip, put the collar on first for several days to a week. Dog should not associate it with pain or correction. Then when you start training, start with just the beep, and if necessary, use shock at the lowest possible setting. And this is only after walking the dog along the perimeter for several days, correcting by verbal command when crossing the line.
E-collars can be good, but they are not for teaching the dog. Teach them first, then correct them as little and with as low a correction as possible. Too much shocking right off the bat will teach them fear, not obedience.