I found a solution on the Scratch website: http://scratch.mit.edu/projects/joefarebrother/1734397
Here is my version:
I created a sprite with 3 costumes:
When the green flag is clicked, set the costume to costume 1
I used a variable turn to determine if a naught or a cross will appear when the sprite is clicked.
To compare whether you have three in a row, I also created a variable 11 for the sprite in column 1 row 1 and set the value to 11. When the sprite is clicked I will change this value to X or O
The code for when the sprite is clicked, looks as follows:
The if statement is very long to compare all possible rows of three (8 combinations).
Duplicate the sprite 8 times and change the code only where the variable 11 is set to X or O
My project is uploaded at: