.com is the standard top-level domain, but when should I not use
.com? What are the most common alternatives? If someone has
foo.com registered, should I choose a different domain or register
.com is supposed to indicate a website is a company's commercial presence on the web. They may sell stuff on it or they may simply use the site to promote themselves as a company (i.e. marketing).
.net is supposed to be a company's web presence online. A common use of .net was ISPs who used it for email.
.org is supposed to represent an organization, typically a non-profit.
In reality many people use .net when the .com is taken and even .org simply because they are the most recognized TLDs. .com if of course the most recognized and the general rule is to try to get a recognizable/memorable .com first because that will be the easiest for a user to remember. It's not uncommon for someone who types a domain name into their address bar to type .com instead of .net (or others) simply out of habit or forgetfulness. But if you cannot find a suitable .com but can find a suitable .net (or others) then you should use it because a memorable .net is better then a difficult to remember .com (or a .com that doesn't really indicate what the website is about).
I would buy the .com TLD of your domain no matter what unless you are a not for profit and plan on buying the .org. Even then I would buy the .com as well just to so no one can squat on it and compete with your site if it becomes popular enough.
Also, if you are in a country outside of the US I would purchase the ccTLD for that country as well. In that case, if you are specific to one country, it is often times best to point the .com domain to the ccTLD domain because Google does use the domain name for country specific searches and some things with language.
Finally, purchasing domain names, especially for companies, isn't so much about which TLD you should have but about how to strategically purchase all domains and possible TLDs that relate to your company's name, branded products, services, etc. Since unowned domains cost so little to purchase it is infinitely easier to purchase everything related to your company now than deal with squatters and court cases later on. In addition it allows you space to grow. For instance if you buy the .mobi TLD for your domain but don't get around to developing a mobile version of your site for 4 years, what are you out of? Probably about $40 which is relatively speaking nothing.
As an example to this strategy, the company I currently working for is a small manufacturing and engineering firm but they own over 300 domains. Many of these are the same name with different TLDs. Even with that we have had to deal with 1 or 2 squatters on similar names. So there is a lot of value in just covering yourself to begin with.
If you are based in a country that has its own ccTLD and/or you are mostly targeting the audience of said country then use that ccTLD (pretty much all my sites are .is).
If you are running a site for a non-profit organization you should use .org (e.g. archive.org).
Otherwise, you should try to use .com. To quote Joel Spolsky
.coms are a million times better than other TLDs.
example.com is taken and you register
example.net instead, you are just asking for trouble if either your site or theirs becomes successful.
I've noticed .com is the standard, but when should I NOT use .com?
In the past, .net was used to indicate internet services like ISPs and .org was used to indicate non-commercial interests (i.e. organizations that did not fit the commercial gTLD). These days, both of these gTLDs are unrestricted so there aren't really any hard and fast rules. I think in a lot of cases it comes down to personal preferences, but you should still have the .com for reasons I'll outline below.
You specifically mention using gTLDs, but another reason you might not want the .com to be your primary TLD could be if you're focusing on a specific country. For instance, I'm Canadian, and it's a minor point of pride/distinction for my blog, so I didn't bother registering the .com TLD, choosing instead to use the .ca ccTLD (country-code top level domain) to indicate that the site is Canadian-run.
If someone has the foo.com registered, should I choose a different domain or register foo.somethingelse?
I think the common advice for this situation is to find a different domain name, especially if the .com is owned by a competitor in your space (there could be legal issues in that case as well). The reason being that .com tends to be the "go-to" choice for domains, and is most easily remembered by the general public. Even if you don't own the .com, a lot of people will likely still end up there simply because that's the default TLD for a lot of users. You'll end up diluting your brand at best, or helping a competitor at worst.
When it comes to registering other TLDs, I've always heard it recommended that you also get the .com for security, and just redirect it to your TLD of choice.