If a the sound device is enabled in Virtual Machine configuration you can connect/disconnect it when guest OS is running.
Note: If the guest OS is started with the sound device disabled, you should shut down the OS first, then enable sound device in the Configuration Editor (select the Enabled checkbox in the Sound Options tab) and restart the guest OS.
To connect or disconnect sound device, you should do the following:
Note: There is another way to connect/disconnect sound device. Right-click sound device icon
on the status bar to display context menu and select the required command.