In a nutshell, the Oyster Card is a smart card. You touch in and out at the start and end of your journey (with the exception of buses and trams, where you only touch in).
The system reads where you started and where you ended and automatically calculates the cost of the journey, then subtracts that amount off your card.
Check out the rates here: TfL adult rates.