Here is the best, clever and optimal algorithm: (This is a well known trick, so I don't boast, only praise the algorithm)
Definitions: The cells are named as follows:
A31 A32 A33
A21 A22 A23
A11 A12 A13
The pieces are W(hite) or B(lack). There are 8 winning combinations: [A11,A12,A13], [A11,A21,A31], [A13,A22,A31] etc. Give each combination a name: C1..C8.:
C1 =def= [A11,A12,A13]
C2 =def= [A21,A22,A23]
C3 =def= [A31,A32,A33]
C4 =def= [A11,A21,A31]
C5 =def= [A12,A22,A32]
C6 =def= [A13,A23,A33]
C7 =def= [A11,A22,A33]
C8 =def= [A13,A22,A31]
Define a mapping from cells to a set of winning combinations:
A11 --> C1,C4,C7
A12 --> C1, C5
A22 --> C2, C5, C7, C8
etc.
So every cell A points to those combinations that has A in it.
Keep a set of possible winning combinations for both players. In the beginning both players have all 8 combinations.
Poss_W = C1, C2, C3, C4, C5, C6, C7, C8
Poss_B = C1, C2, C3, C4, C5, C6, C7, C8
When W plays in a cell A, delete the corresponding winning combinations from B. For example when white plays A12, delete C1, C5 from Black's possible winning combinations list.
After the game ends, the player with a nonempty possible winning combinations set wins. If both Poss_W and Poss_B is empty, the game is a draw.