Accents are in general imprinted by your environment. If you are young enough then your friends have a lot to do with this - you are fitting in to the local environment. - Hence Indian parents who bring children to the Canada speak their national language but the children learn and speak with a Canadian, and often regional, accent.
Once the basic speech patterns have been established it takes considerable effort to over come them. Muscle memory take over from conscious effort and you have to re think these established patterns. Thus some people have the ability to mimic any accent quite well, but by no means all can do that.
Children start to acquire the syntax of their first language around two, and it ends around five or six. Once they reach that age, they've pretty well acquired all of the syntactical structures of their first language, and operate at the adult level in terms of grammar (but not vocabulary, obviously).
I would assume, therefore, that regional or dialectical pronunciation patterns would be mastered around the same time, if not much earlier.
Here are a couple of pages that explain the process of First Language Acquisition in more detail: