Since Tic-Tac-Toe is a solved game, I would recommend simply playing a perfect game every time.
The following algorithm will allow you (or the AI) to always deny your opponent victory:
If you have two in a row, you can place a third to get three in a row.
If the opponent has two in a row, you must play the third to block the opponent.
Create an opportunity where you have two threats to win (two non-blocked lines of 2).
- Blocking an opponent's fork:
If there is a configuration where the opponent can fork, you must block that fork.
You play the center if open.
- Opposite corner:
If the opponent is in the corner, you play the opposite corner.
- Empty corner:
You play in a corner square.
- Empty side:
You play in a middle square on any of the 4 sides.
Pick the highest possible on the list
The perfect heuristic is pretty simple in terms of AI programming. The most difficult heuristic part to implement is searching for fork configurations. Once you have that the other checks are next to trivial!