After betraying Robb Stark, Theon snuck into Winterfell while Ser Rodrik Cassel fought at Torrhen's Square and captured the castle. He tried holding on but got arrested by Ramsay Snow, disguised as Reek.