I've never bought a ticket so I am not sure how it exactly works.
Do I actually pay for the ticket when I'm reserving it online? Or do I pay for the ticket when I go to the airport?
Generally it'll depend on who you bought it from, but almost without exception these days, you pay when you reserve the ticket.
Usually it'll ask you for your credit card details when you purchase it. It may take a few days to charge you for it, but it will be charged.
It's possible with regional airlines, or tourist flights to reserve and then pay on the day (eg the sightseeing flights in Vancouver, Canada), but regular airline flights, you pay online.
It is possible to reserve without paying but this usually only lasts 24 hours. I have seen 48 hour offers but those are rare too. In this case what you are doing is reserving a spot which you can buy later at a set price. It does not last long because the airline wants to close the deal and be sure that someone buys the place.
The vast majority of time, you will be paying immediately the full price of the ticket at the moment you buy it. This is the case for buying directly from airlines and aggregation sites like Expedia, Orbitz, etc.
You may have to pay more later, up to the time of check-in. Nowadays, baggage fees are common and so are seat selection fees. If you do any of those after purchase, plenty of airlines will charge you at that time. Most tickets nowadays include airport departure fees but this is still not true everywhere. Should it be the case, you may have to pay at your departure, return airport or both!