In the Season 3 scriptbook, there's a scene that wasn't ultimately filmed and/or aire where Bates asks Thomas if he has anything on O'Brien  that he can use against her.  We did see that part.  However, in a scene that wasn't shown, Thomas tells Bates something along the lines of "I swore I'd never tell."  So more than likely O'Brien told him.