I always defrag after installing software and at least twice a week. Think of it like a filing cabinet, you have to make sure that all the files are in the correct place to make it easy to find them. The longer you avoid defragging the longer it takes to do it. Just defrag regularly; easy peasy.
It depends on how much creating, extending and deleting of files you do. It would make more sense to defrag BEFORE installing new software, that way the software will be installed unfragmented in the first place.
Quicksilver and pcwork's answers aren't really correct, for today's computers. Assuming you're using a fairly modern file system (I'm thinking NTFS on windows XP -- you probably are), and have a fairly large hard drive (>50GB), then defragging once a month or even less will suffice.
What's true is that older file systems, like FAT32, or any file systems running on smaller drives, will need defragging more frequently, typically once a week or so to keep at optimum.