The transaction fee is added to the Coinbase subsidy (block reward) by the miner, based on total fees contributed by the transactions within the block itself. This way, transactions don't have to send the fees to the miner directly.
Block Reward = (Base block reward + tx fees)