Historically, yes, it was a paid game. It's worth noting that Team Fortress 2 later became free-to-play on Steam, so the answer depends on when you're asking. Originally it cost money, but it's since been made free with optional in-game purchases.