If it is Windows, Yes. If it is Macintosh or Linux, No.
Also versions of Windows Vista and newer normally are set to do disk defragmentation automatically, so you just want to make sure you have it set to do that and it is working.
If possible, You don’t want to do defragmenting while the computer is being used for something else.