With the built in XP defrag which is actually made by the Diskeeper Corporation, once a month, before updating my backup drive images and after deleting the contents of the prefetch folder and generally cleaning up the drive.
If you install Diskeeper 9 Professional you can leave it on Smart Scheduling and have it defrag seamlessly in the background, but I would advise you to have between 512 and 1024 MB of RAM.
Diskeeper 9, Professional version, has the advantage of incorporating Frag-Shield, unlike the Diskeeper 9 Home version, which is useful if the Master File Tables ever need to be adjusted.
Diskeeper 9 Professional version with Frag-Shield can be used on XP Professional or XP Home Edition.