I don't understand how you can buy iPhone with contract for a year and not to pay for that year.
It doesn't matter if you took that phone to another country, you have obligation in US.
You WILL have charges in US and your local carrier.
Am I right?
Partially... you will still have whatever contractual liabilities you set up with AT&T in the U.S., but if you unlock and go to another country, obtain local service in that country, with a new SIM on a contract or "pay as you go" plan, you will be working with and paying only for the foreign carrier whose SIM is in you phone at that time. If you were to switch you AT&T SIM back into the phone while in that other country, you'd be "roaming" (perhaps on the same carrier), but paying rates through AT&T.
Keep in mind, regardless of how long you are away from the U.S. your AT&T contact is running and even if you are not using any airtime or data on AT&T, you'll be responsible and billed each month by AT&T as though you had, with absolutely no connection to anything you might be doing when the foreign carrier's SIM is in your phone.
So, you might take your total cellular liability into consideration here. If you plan on taking out a contact with AT&T that's costing you, say, $50/month, but will be out of the U.S. for a full month, you might as well use that $50 worth of service AT&T will be billing you for anyway by roaming for that amount of time, then put your foreign SIM in the phone for the rest of the time. "Use it or loose it."