When to go to war? Depends on the victory conditions. If those call for galactic domination then all alliances are temporary, though they may Last for over 5 years. Usually when I run out of room to expand I pick a target which is close by and a threat to my frontier, and start provoking them. However I must do this in-char (roleplaying) so it isn't always easy, unless you play a xenophobic berzerker race

What sometimes works against humans is demand they give you stuff or reduce their fleets or such until they get fed up an break their treaty

Or, make friends with an enemy of your target and find a reason to help that enemey against your target, e.g. if you are merchants you could say you were bribed with promises of tech and colonisation rights...
etc etc, be creative :-)