could be the cable falling out (it happens to the best of us), but if its a regular occurence it might be due to faulty memory on your sound card, screwy drivers or any number of things. if it happne with all games, switch your sound card into another machine and see if it works there. if it still breaks, go get a new one.
unless this only happens under BG1&2, in which case you should goto
www.bioware.com and check their faqs. if it happens in other games its likly drivers or hardware.