Whenever it furthers our national interest. And to clarify, that means that the whatever we're seeking to gain or protect by going to war has to be worth more than the cost and long term ramifications of going to war. So nation building and playing world cop don't further our national interests sufficiently to justify the cost of war. But conquering the American west and completing manifest destiny in the Mexican-American War, that was worth it.
Generally, I favor non-intervention. I think our self interest is usually served by butting out of the affairs of other nations. But if our interests do compell us to act, then we should act swiftly and harshly, ruthlessly pursuing our self interest.