I live in Maine, so hopefully my opinion isn't too biased lol. The entire Maine coast is beautiful. Ogunquit, Old Orchard Beach, Kennebunk are all great areas. The only problem is during the summer they get very crowded and busy. York's wild animal kingdom (in York, Maine) is amazing for kids, and parents alike. Our kids at 9,8,8,5, almost 2 still enjoy it every time we go. Then there is also Funtown/Splashtown USA in Saco which is great place to spend all day having funif you like amusement parks and water parks. Portland is naturally the hotspot for nightlife, and the Old Port in portland is a historic area (a little history never hurt kids) and very beautiful with great shopping for mom and dad. A little further up the coast is Camden/Rockport/Rockland area which has the schooners, again, with a lot of history, and the Boat show, Blues Festival, and Lobster festival every year if you like small town carnival type things. Bar Harbor is also great, and has plenty to do at all ages.
Finally, there is my personal favorite, North Conway, NH which is where our entire family (us, my in-laws, sisters and their families together) vacation every year. It is an absolutely beautiful area. Fun for all ages is to be had (kids in our family range from 14 to almost 2). The area is complete with a natural spring, tons of shopping for the adults, great restaurants.... I could go on for a while.
The Maine office of tourism could help you with more information on which areas you specifically are interested in, and I'm sure New Hampshire has something similar. Enjoy your vacation, hope this helped.