A K is really a overrated hand in my opinion, when it comes to how long you hold it. I've seen my friends hold it down to the RIVER without catching.
But seems like you played it right, not your fault he had the set, he could've had the set of 2's and had it obviously, sets are tough because they're sneaky, someone who calls your bets, big - then bigger, you have to wonder. Do they have a set? But it seems like you can't fold top pair, top kicker. Even when you should.