Cancellation of sound coming out from speaker while recording?
This is a very complex signal processing task known as "echo cancellation". Some open source voice encoders have it selectably built in (such as Speex). I believe that some Bluetooth hands-free devices have this too, if that is an option for your system.

Sidenote: It can actually be present at multiple locations in a voice chat (bluetooth hands-free, cell phone, telephone carrier, remote VoIP system, remote speakerphone) leading to large and annoying delays, since each echo cancellation step adds a small amount of delay.

To my knowledge this is not something that is available to simply 'plug in' very easily, unless you spend some big money.. but you might have luck looking into those open source voice encoders.