It's sometimes difficult to find the right information but everything is somewhere on the EU website. Wikipedia has a good summary as well. Some embassies or government websites from the various Schengen countries also provide useful summaries. Legally, the main source for all this is the Schengen visa code.
Here is a step-by-step guide through the rules to decide if you need a visa:
1. Are you flying within the Schengen area?
If your next destination is in the Schengen area, you must pass through passport control to get to that flight, so you need a regular Schengen visa unless you qualify for visa-free entry.
If you're going to somewhere within the Schengen area and already have a visa issued by that country, this visa also allows you to enter the Schengen area at a layover point in a different member country.
2. Can you enter the Schengen area?
If you can enter the Schengen area, you can also transit there. You can enter the Schengen area if you are an EU/EFTA citizen, hold a Schengen visa, a long-stay visa or residence permit from one of the Schengen countries, or are a citizen of a country whose citizens don't need a visa to visit the Schengen area. If any of these apply, you can stop here, you don't need a visa. If none of these apply, read further.
The list of countries whose citizens don't need a visa to enter the Schengen area can be found on Wikipedia. They are also colored green on this map from the EU Commission.
3. Can you transfer without leaving the international area of the airport?
Many airports in Europe have an international area with transfer/check-in counters, waiting area, sometimes lounges, restaurants, shops or even a museum before the border checkpoint where the police check the passports of passengers entering the Schengen area. Gates for non-Schengen destinations can be accessed from this area, whereas domestic and Schengen-bound flights depart from other parts of the airport.
Whether you can transit without leaving this area will depend on your specific connection (airport/terminal, airline, time). For example, some German airports close at night, so that it's not possible to remain in the international area for an overnight transfer. Luggage belts are typically after the passport check so if your luggage cannot be checked through to a destination outside of the Schengen area, you will also have a problem.
Finally, as passengers' passports don't have to be checked on flights within the Schengen area, if you have two stopovers in the Schengen area (for example Mumbai-Vienna-Frankfurt-Chicago or Nairobi-Zurich-Frankfurt-Chișinău), you will have to leave the international area and go through the border checkpoint to catch your intra-Schengen flight. Same thing if you need to change airports.
If you have to leave the international area to make your transfer, you cannot transit without a visa and you need a full Schengen visa (and not merely an “airport transit visa”). If you can stay in the international area (“transit airside”), read further.
4. Do citizens of your country require a visa to transit airside?
If you have come so far, it means you come from a country whose citizens require a visa to enter the Schengen area. But there is still a distinction between two categories of countries among them. While most people can transit airside without a visa, citizens of a smaller list of countries need an “airport transit visa” even if they don't want to go through the border checkpoint and enter the Schengen area.
Where things get complicated is that the list of countries whose citizens need an airport transit visa is slightly different from one Schengen country to the other. There is a list for the whole Schengen area (list in Wikipedia, dark red/burgundy on the map from the EU) but individual Schengen member states can also add countries to the list. They have to inform the Commission, which keeps a list of all these requirements (current list as PDF, see also the same Wikipedia article).
If your country is not on either of these lists, stop here, you don't need a visa. On the other hand, if your country is on one of the lists (the general Europe-wide list or the one from the country where you are going to transit), you might need an “airport transit visa” but read further as there are some exceptions.
5. Are there other rules that could allow you to transit without a visa?
If your transfer requires an airport transit visa, there might still be a way to transit without a visa as the Schengen Visa code provides for a number of exceptions for people who hold some other visas or residence permits. Note that those exceptions only apply to the airport transit visa requirement. If you need to enter the Schengen area (see question 2), these exceptions do not apply.
Specifically, you are exempted from the airport transit visa requirement if you hold a valid visa from an EU country (that's the whole EU, not only the Schengen area so also Ireland, the UK, Cyprus, Bulgaria, Romania, and Croatia), Canada, Japan or the United States of America. Germany also recognizes this exemption for travelers returning from the any of the above countries even if their visa is expired, but you should check with the country you're actually transiting through, because this exemption is not mentioned explicitly in the Schengen codes.
You are also exempted if you have a residence permit from one of these countries or from Andorra or San Marino. If that's your case, you are exempted even if you are not traveling to this country.
If you hold such a visa or residence permit, you can transit without a visa, no matter your citizenship or your destination. If you don't, you will need a visa.
Furthermore, if you just used the visa (so that it's not valid anymore but expired recently), you can still transit without a visa in the Schengen area for the return trip. This rule does not fit US visas very well because it's possible to stay legally in the US long after your visa expired.
Schengen regulations stipulate that holders of expired US visas can transit in the Schengen Area without a visa if returning from the US after having used the visa; however check-in clerks may exercise an overly cautious interpretation regarding US visas expired by a large amount of time, and consequently deny you boarding.
As such, in this case it is highly recommended to get a written confirmation from the ground handling personnel at the airport of departure well in advance, or apply for an airside transit visa for the Schengen Area.
6. Can I get this visa on arrival?
No, you cannot. There are provisions for 15-day single-entry visas on arrival in limited cases (mostly seamen, EU citizens' family and emergencies) but it's not regular practice in Europe. If you need a visa, the airline/ground handling personnel at your departure airport will want to see it (they can be fined if they transport you without checking) and they will deny boarding if you don't have the right to transit in the relevant airport(s).