The question of when to address coloring inside the lines is actually a question of child development, especially fine motor skills.
While there could be philosophical arguments about whether it's good or bad for a child's creativity to have them work inside the constraints of lines, I believe that clouds the specific issue (and is a different question). Instead, we need to focus on whether or not it's a task the child is actually capable of.
#When can children stay inside the lines while coloring?
Much of the information out there points to the same age range, but this article, Fine Motor Development 0-6 Years (PDF), summarizes it quite nicely:
3 to 4 Years
Your child will have a strong
preference for a lead/dominant
hand, but switching continues.
When drawing, the lead hand will be
holding the crayon while the assist
hand is stabilizing the paper. Your
child will progress from being able to
copy lines & circles to imitating
crosses (+) & tracing over triangles
& diamonds. The child will attempt
to colour within the lines but with
limited success. By 4 years of age,
your child should be holding the
crayon with three fingers
And:
4 to 5 Years
During this stage hand use is
characterized by refined wrist &
finger movement & decreased elbow
& shoulder movement. During
drawing, a combination of finger &
wrist movement should be observed.
Hand dominance is typically
established between 4 & 6 years, so
a hand preference should be
apparent & consistent. As a result,
the skill of the dominant hand should
begin to exceed the skill of the nondominant
hand. During colouring,
the child will become capable of
staying within the lines as well as
copying crosses, diagonal lines &
squares using a tripod pencil grasp.
What we see here is that around the age of 3, children start being developmentally capable of trying to stay in the lines. This has to do with a combination of cognitive ability, grip, and fine motor control.
Then, sometime during their fourth year, children become more adept at staying within the lines.
It's important to note that these are generalized developmental milestones, and not hard and fast timelines.
This study, Descriptive Analysis of the Developmental Progression of Grip Position for Pencil and Crayon Control in Nondysfunctional Children, found some trends in the way children hold their writing/drawing implements based on their age. They identified two "mature grips" that are essentially the traditional pencil grips we're taught to use. While age breakdowns available in the article are interesting, this excerpt really highlights the concept of development:
Coloring
During the administration of the coloring task, we
noted that often the children would first color the
edge of the circle using a more mature grip and then
color in the center of the circle using a less mature
grip. This was more noticeable in younger children;
older children would simply slow down to color the
edge and then continue with the same grip for the
center of the circle. We chose to analyze the grip used
to color the center of the circle.
What this clearly shows is that children typically need to have the fine motor control and grip strength necessary for a traditional, "mature" grip in order to stay within the lines. They may start using that method just for the edges, while going back to the physically-easier methods of coloring the insides of the drawing until their grip strength and stamina improves.
##How does this answer the question?
It lets us know that, at a minimum, this shouldn't be a concern for parents until around the ages of three or four. Unless there's a clear developmental problem, there probably doesn't need to be any extra coaching on the matter. Children will develop the grip necessary to complete the task most efficiently as they get older.
The most effective way for them to improve their strength and control is by giving them plenty of opportunity to practice. Rather than focusing on whether or not they're able to stay in the lines, you should focus on whether or not they're getting enough opportunities to develop.
##When should you actually tell children to stay within the lines?
There may be a time when it's appropriate to advise your child to specifically be mindful of the lines. This would be a time after you know they've already developed enough to be capable of minding the boundaries, but for reason they aren't doing so.
A clear example is one from my own youth: I would often rush to complete a drawing or coloring page, and in my excited impatience fail to take the time necessary to stay in the lines. Here, my specific problem was more behavioral, and a reminder to take my time and to be calm would help to address the problem.
I expect this to happen sometime around age six. Six years old is frequently seen as a delimiter between stages of artistic/fine motor development in children. This chart, Drawing Development in Children, shows that two other drawing development experts believe a new stage of drawing development starts around age six.