Did Winston know that O’Brien was a part of the Party or not?
No. Winston believes that O'Brien is an ally working against the Party from the first moment he spots O'Brien's seemingly unorthodox disposition at work. Winston is intrigued by O'Brien's behavior during the Two Minutes Hate period when he makes direct eye contact with him. Winston interprets O'Brien's stare as his way of saying,
I am with you...I know precisely what you are feeling. I know all about your contempt, your hatred, your disgust. But don’t worry, I am on your side! (Orwell, 22).
Winston believes that O'Brien shares the same ideas regarding the government as him and even begins to dream about colluding with O'Brien against the Party. Later on in the novel, Winston accepts O'Brien's invitation to pick up a Newspeak Dictionary at his home. Winston and Julia even travel to O'Brien's home, where O'Brien manipulates them into believing that he is a member of the Brotherhood. Winston pledges his allegiance to the Brotherhood and accepts Emmanuel Goldstein's book. Winston is utterly surprised and disheartened to learn that O'Brien is a government spy. O'Brien then becomes Winston's main torturer in the Ministry of Love. Overall, Winston trusted and believed that O'Brien was an enemy of the Party, when O'Brien actually worked for the government.