WindowWatcher is a FREE application that records to a SQLite database which window and application is in front of all others.  The data can be exported in tab-delimited or Property List (PLIST) format.  Just start it and leave it!

WindowWatcher is useful if you want to:
Minimum OS: 10.4.  Download here.

WindowWatcher is FREE for your personal use!

If you'd like more functionality, such as automatically starting and stopping time records based on the front window, check out TimeSlice.

Sample screen-shots

WindowWatcher developed by Modesitt Software