A UTXO cannot be cut in half. It is spent whole, like a banknote. If you owe 0.01 BTC and your wallet holds one UTXO of 0.5 BTC, the transaction spends the whole 0.5 BTC.
Giving yourself the change
The transaction then creates two outputs: 0.01 BTC to the recipient, and about 0.49 BTC back to a new address of your own wallet. That second output is the change. What is left between the two, a small amount, is the fee.
- Input: 0.5 BTC
- Output 1: 0.01 BTC to the recipient
- Output 2: 0.4899 BTC back to you, the change
- Fee: 0.0001 BTC, collected by the miner
The classic mistake
Wallets create the change output for you. People who build transactions by hand sometimes forget it, and the whole difference goes to the miner as a fee. Some very large fees in Bitcoin's history were exactly that.