2nd weekend of October would be when I'd go for Maine, maybe 3rd but after that it would be pushing it and a lot of places close down for the winter at that time. A week can make a huge difference in leaves as well as how far north and inland you go. I drove the Kangamangus highway (great place to see leaves, part of the national park with plenty of areas to pull off) the second week of October full colors, the third week I went back that direction and a windstorm had dropped most the leaves. If your looking to take the cog railroad to the peak of Mount washington, make sure you check the dates for the last scheduled trip to the top. The further north you go the earlier the peak of the colors.
Book your housing early, it can get expensive. I lived in Dover, NH during the fall a few years ago for work and it was very difficult for my company to find housing.
Keep an eye out for the 2023 peak fall colors prediction map. It might help you decide when to go.
You might also look at going to Portsmith, NH to base out of for peeping.