In Maine I'd try Eliot, South Berwick, and Berwick. They are right by Dover but might be a bit cheaper. Sales tax is mostly irrelevant as you'll be shopping in NH.
Madbury in NH is another idea that should be cheaper than Dover. Decent town, right near UNH (lots of activities there, hockey football, music, etc). I'd check out Kingston and Brentwood as well.
Somersworth and Rochester are cheap but scuzzy. There are decent areas in the rural outskirts though. Lots of poverty and substance abuse in the downtown areas. They aren't dangerous places, just economically depressed and a little weird.
Overall I'd stick moderately close to Route 16 (Spaulding Turnpike). It makes travel go just about anywhere so much easier.