Assuming you want it to work on layouts as well as "proper" tracks you could do it a couple of different ways. The two that immediately spring to my mind are as follows. There are probably more.
The simplest would be to probably consider the track as 2 2D overlapping polygons. One that has the bounding edge of the "outside" of the track. The second is the "inner" edge. You then just use a point-in-polygon algorithm to determine if its outside of the first polygon then it's off the track on the "outside". If it's inside the second polygon then it's off track, on the "inside". Edit: The problem with this is that it sucks at tracks with overlapping sections
An alternative would be to consider the track as a single path (Edit: Path not polygon), using the center or racing line as the path, and knowing the distance from each point to the 2 (Edit: or 4 if you wanted up, down, left and right of the path) edges of the track. At the start of the race/at load/whatever build and balance a tree structure using the path coordinates to minimize the number of points you need to search each time. Everytime you want to check you use the tree to get the closest point on the path, then calculate the direction and distance to the path point from the players current position. You then know if its on or off track from the direction and distance. A little harder, probably more work to maintain, but may be potentially quicker to do every second. Edit: The benefit is that you get 3 dimensions and it should work properly for overlapping tracks.
Would it not be better to do on a time basis (if car doesn't move for x seconds then they are considered as retired) just in case someone parks on track but where the retiree might consider safe as its off the normal racing line - like a long straight or entrance/exit of an unused pit?