If I were the President of the US?
I would start immediate investigations of CIA and FBI archives, to see if in those archives there are a billion and three reasons why someone might have struck at the country I serve. I would figure out who and what the group(s) is / are who attacked the country.
Call in the expertise of people who understand psychology and sociology, and the impact of poverty, violence, relgion, et cetera on a population. Call in of course the people of the secret services to gather information on why things happened, and the names of the people who are behind it. So as to understand why the specific thoughts of such a terrorist group sprang up.
Religious fundamentalism has not always existed in the extents as it exists nowadays. Investigate that (one reason I would never get elected: I take too much of an issue against religious fundamentalism, no matter what religion it comes from).
Now, if it is because of opposition because of a military presence of say Saudi-Arabia, I would wonder why those troops are there, and are not basically Saudi troops (excepting of course the bases where nuclear weapons are stored).
Of course, if a country actively supported terrorist groups (Saudi-Arabia is one of those, but has not been attacked), take a stance on that. Blockade them, economically speaking, if they are not cooperating, and of course seek support from allies. With the US being the most powerful country in the world, it is not hard to manage to get a strong coalition (and which country was opposed to the Afghan war?). Apparently, the US is coming down to such a position with Saudi-Arabia.
Work for ways to lessen presence and influence (force) in such countries, as it does not serve a military purpose; the cold War is over.
Opening countries for democracy, as the US often demands of regimes it opposes, such as Iran. If democracy is holy to the US, the US should be consistent in its demands for democracy. And not when it suits US interests. Egypt has issues with that, Syria has, Iran has, and Saudi-Arabia. To attack two for their lack of democracy makes it obvious the US does not really care about democracy in their foreign policies. And that should change.
Make work of the Israeli-Palestinian conflict. A conflict where we are highly involved in, and certainly perceived to be supporting Israel in. Of course, not everyone will be happy with whatever solution that is proposed. But the value of freedom and peace must not be underestimated either. For the Palestinians and the Israeli's.
Compensate countries all over the world, for the lack of respect shown to national soveignity (the Chileans were mentioned earlier in the thread, but also El Salvador, amongst others), to restore popular confidence (of the people) in those countries in the US again. If you play it smart, the US industries will be profiting from that as well.
End the unilateralism. US servicemen, politicians et cetera should also be held accountable for their actions, and possibly even prosecuted for crimes against humanity and other war-crimes. Unless of course, the politicians are serving in an official position in Federal governments (similar to other countries).
Have respect for all religions, and promote openness on religious matters.
The less reason people have for hating a country, the more it will be appreciated - and if it is not perceived to be a hypocritical country - there is a lot less reason for people to attack it.
Remember the support after 9/11 for the US was very big worldwide. 4 years later it has crumbled to dust - and business is back at usual. Missed opportunity

and I am sad to say that if nothing changes it is waiting for the next disaster.