Often times the nature of the cubicle farm itself can lead to this issue. Try to avoid these conditions if you have control over your office environs -
“Open Office” plans where you are compelled to hear your neighbors conversations.
Having one phone for several people in your area so you cant disconnect it and have to attend it on the off chance it yours.
Conversations over information that can be sent by email or IM or SMS or any of the multitude of asynchronous forms of communication available today.
If you don't have control over the office environs, here some things you can do -
Some people wear head-phones to block the ambient noise and subtly indicate to people they are working on something and interruptions are not encouraged (YMMV – I have seen people ignore the subtle indication and come over anyway).
Some people deal with all their email and IM at scheduled intervals – this way everyone gets their reply and people learn to come with the questions at those times.
It is necessary to keep a balance being too focused for long periods of time can lead to burn-out. Check out this blog post for some more info.