The audio system in OS X offers audio processing, MIDI, input and output, and other capabilities to programs through a central Core Audio framework structure, allowing for easy audio implementation into programs and system services. Generally, you interact with the audio system through System Preferences, Apple's Audio MIDI Setup utility, or the settings of specific programs like GarageBand, but if an error occurs such as no sound, scratchy audio, a repeated audio loop, lack of device recognition, or other problems, then you may have to work around it in several ways.
The first step if a problem occurs is to check whether it is systemwide or only in the program you are using. Try opening a new audio program, such as QuickTime Player, and use it to record or play back some audio. If this works, then try changing an audio setting or two in the program that is experiencing problems. This can be as simple as toggling a bit rate change, switching between output devices, or some similar feature that will hopefully be enough to reinitialize the audio drivers. However, if this does not work, then you may have to quit and re-launch the program.
If the problem appears to be global, then the next step is to reinitialize the system's core audio daemon process (coreaudiod), which is a persistent background process that handles audio processing in OS X.
As with handling audio processing errors on a per-application basis, you can try toggling some audio format and input/output device settings in the Sound panel of System Preferences, or using the Audio MIDI Setup utility that is in your Applications > Utilities folder.
If this does not work, then you may need to reset the audio daemon, which can be done by rebooting your system; however, this may not be desired if you are in the middle of a workflow and would prefer to keep your system operating. In these cases, you can manually reset the audio daemon, by simply forcing it to quit. This can be done by opening the Terminal utility and running the following command:
sudo killall coreaudiod
If you would prefer to use a graphical interface tool for this, you can launch Activity Monitor, select "All Processes" from the View menu, and then search for "coreaudiod" in the process list. When found, select it and click the "quit" button in the Activity Monitor menu bar.
Either of these actions will quit the "coreaudiod" process, but since the process is loaded by a LaunchDaemon script that instructs the system to keep it alive, the system launcher (launchd) will immediately launch it again. This should re-initialize it, and its interface to any external devices you have configured for it.
Note that this approach will help the processing of audio, but will not necessarily help with an inability to detect an audio device. If the device is off-line, or there is a USB driver problem, this will not fix that issue, and likely a full restart of the system will be necessary to bring the device online again so the audio system can properly interface with it. This may be apparent if a laptop will not switch between headphones and internal speakers.