The article of clothing that Dobby caught that set him free was Harry’s sock.
For a house elf to be set free, his master has to give them an article of clothing. In the chamber of secrets, Harry put his socks inside a diary.
Dobby’s master throws the diary on the floor not knowing that there was a sock inside and then he told Dobby to pick it. When Dobby picks up the diary, he opens it and sees a sock. Technically, since his master “gave” him the diary with the sock as an article of clothing in the diary, this sets him free.