This answer to this depends on your parenting style. Some believe you need to set rules and schedules starting in infancy and others, like my husband and I, believe that raising a child means making decisions based on the child and other factors. They way we parent is sometimes called "attachment parenting." We allowed our children to be close, feel loved and safe, and form strong attachments to us. Now that they are teens is has paid off 100 times over.
If you do plan to make them stay in their own bed, then the answer below holds true. The longer you let them stay, the harder it will be. We also waited until they were asleep and put them in their own beds. If they came back later, it was still OK. We reasoned and encouraged them to sleep in their beds, but understood when they were afraid, lonely, or sick. What always stuck in my head was that they saw that Mommy had Daddy to keep her company, but expected the little ones to be brave and go it alone. I admit, their were many nights of interrupted sleep, but trust me, they eventually want to sleep in their own rooms. It's really a short period of time compared to the rest of their lives, and it makes them feel safe in the world.
For my children it wasn't exactly a specific age because it happened over time. My daughter, who has OCD, came back to sleep on the floor in my room when she was 9 because of her terror at night. At the time I had no idea she had OCD, and now I am glad we worked through that time in a loving way. My son was simpler, and he stopped coming in to see us by 5 or 6. Probably by the time he was 4 it was infrequent, but it still happened.