Edit: Incorrect answer. I achieve 'never lose' but not 'win when possible'.
I think I have a working strategy.
Step 1:
Play as X.
Step 2:
Before your first turn, ask this: "If my opponent wins, will it be along a horizontal line?"
Step 3:
Regardless of the answer, play in the centre.
Step 4:
After the opponent's first move, play in a corner. This leaves 4 possible board states (removing reflections and rotations). Lines where the O player can win are marked in red.
Now note that regardless of which possibility is true, the O player has only two lines they can win on. Additionally, one of these has become unplayable due to the question. Regardless of what O plays here, X always has a move which blocks O's final possible win line.