Al Pi ShulchonOruch, according toShulchonOruch, Tzniyus, the Laws of Modesty, such as dressing modestly, etc. apply to a girl once she reaches the age of Bas GimmelVeYomEchod, as soon as she turns three years old. While some people are lenient as long as the girls are very young and nobody notices how they are dressed, still the mainstream Halacha--and this is the Rebbe's view --tells us that once a girl is three years old, one should be careful with her Tzniyus. The laws of Yichud, the laws regarding a woman or girl being in seclusion with a man or a boy nine years old and older, apply to her from the age of three, according to all opinions. However, so long that a girl has not reached the age of maturity needed to understand the importance of not entering a men’s Shul, it is permitted for her to enter a men’s Shul. Obviously, this is only provided that she is dressed in a Tzniyusdik fashion so as not to attract unwarranted attention. The ShearimMetzuyonim BaHalacha, my grandfather, ZecherTzadikLivrocho, mentions various ages for girls to enter the men’s Shul at different times.