Since we do not know where the user lives until after they have added the item that cannot be shipped to where they live, and then entered their ship location, I would love to see examples or ideas about how and when to communicate this.
For most commerce sites, you do not want to lead the customer on or p*ss the customer off.
Therefore, letting the customer know as early as possible is the best practice.
If you can determine the location beforehand (e.g. using the methods that @skwotz outlined), then you can filter products accordingly.
But sometimes sites cannot tell where the customer is located, and may not want to ask the customer beforehand because it erects a barrier to browsing.
In these cases, I think the best practice is to show a warning at the item-level:
This alerts the user ahead of time, and allows them to take action immediately if they are interested in the item.
BTW, letting users know beforehand is not always the most successful UX. For some sites, you may actually want users to invest a lot of time filling in forms so that they are less likely to back out of the final purchase. This is rarely the right thing to do, but the answer wouldn't be balanced without pointing out alternative approaches.
It's best to let people know this as soon as possible. It is very disappointing to get halfway through check out only to realize you can't get it shipped to where you want. A lot of large ecomm sites have a modal when you first arrive at the site to select a country. http://www.louisvuitton.com/ I've seen ones where they bring you to a browse only section of the site if your country is not on the list. Often you can also detect the visitor's country based on their IP but this not always the country they're trying to ship to nor is it accurate if they are using a proxy. Other points in which you can make the visitor aware they do/don't ship to their country is allowing them to estimate shipping in the mini cart by entering a country.