Rule #1: Don't lie!
Please don't lie to a coworker (or another manager, etc):
"Yes great idea! I'll do my best"
This doesn't build trust between you and others, and it will actually make you look bad when others learn not to trust you or take you for your word. If you told me you'd take care of something, I feel I should reasonably trust that the work will either get done, or you would come back to me and explain that you're not able to help. This applies whether or not I'm your manager or your peer.
Depends on Corporate Culture:
What you should say and do really depends on your corporate culture. In some environments, where departments are completely separate, it would be bad form for Bob to assign work to another department's employee, but since you didn't say what kind of environment you work in, let's assume that you're part of a somewhat flatter structure (but might not know it yet), and "Bob" is just doing what's considered normal.
Where I work, our structure is relatively flat, and most people work within self-directed teams in order to accomplish specific goals. Thus, it's not surprising to see a sales manager ask a developer if she can jump in on a sales call to explain a technical concept to a client, or for that same developer to look into a bug that the sales manager reported. Likewise, it's not out of the ordinary for a client services technician to step away for an hour to help with an in-house promotional video for another department.
What you could say:
The key is that our own work comes first. We have deadlines, and if there's time, we help in other areas for the greater good of the company. If we don't have time due to a deadline, we might say something like this:
Hi Bob, I can maybe look into that for you, but Larry needs me to get that project charter completed and ready for review by tomorrow afternoon. Is this something that can wait until then? If not, why don't you ask Sally? She has experience with that and might be able to help.
In short, don't be afraid to say no, but be sure you don't drop the ball. Instead, pass it back to "Bob" with some suggestions on who to turn to. However, if "Bob" pushes back, then you could try this:
Okay Bob, let me talk to Larry and explain the situation. I'll see if we can either push back the project charter deadline or see if Frank is available. I know Frank can handle this if necessary.
This works really well in our organization, and it should also work in structures that aren't so flat as well. The key is to be honest, be respectful, and if there really is a problem, contact your direct supervisor for clarification.
Lastly, before applying these techniques (or any other techniques from other answers here) I strongly advise you to discuss the proper behavior with your manager. Corporate cultural norms can vary widely from organization to organization, and this is just meant as a guideline or a means of getting started. For instance, in the US Army, an Army Private telling a Sergeant that he/she is busy may not be acceptable, whereas it may be more acceptable for a developer at a medium sized business as part of a Scrum team to tell a marketing manager that he is working on a critical deadline that's behind schedule.
Either way, in most organizations, it doesn't hurt to be honest and ask for clarifications. If in doubt, ask your manager. Good luck!