You can visit Matheran whenever you want, but the best time to visit is right after the monsoons, which is from September until November and February until March.
You can visit during winter, which is December until February, but during this time it will be extremely cold. The rest of the year the area has nice weather, but after the monsoons it is after the monsoon that the region turns absolutely green. Most people come and visit all year round because of the amazing temperature and use this as an escape to get away from the insane heat of Mumbai. So make sure if you are coming to visit this place, it is better that you book ahead to ensure accomodation.