As mentioned by several others here, it really depends on the license. Some allow you to use their code in proprietary software without problems, some require you to at least include only the open source code that you used, and some require you to declare the entire program as open source. I personally love open source code, but it is important to understand that it often comes with strings attached to it.
While it may be tedious, there is no substitution for reading and understanding its license before you use the code. I can't stress this enough! The license attached to open source code is a legally binding contract that's main purpose is to grant you permission to use the code without violating the owner's copyright. If you can't meet the conditions specified in the license, then using that code is considered a copyright violation and can prevent you from distributing your software.
You also have to remember that if the code you are using has two or more licenses attached to it (or you are using code from different open source projects under different licenses), you have to make sure you can fulfill the requirements mentioned in ALL of those licenses to be able to distribute your program after using the open source code. This can get sometimes be difficult since there is a long list of open source licenses out there, each with their own terms and conditions.
The bottom line is that open source code is really cool and can be very useful to a software developer, but if you need code with no strings attached, your best option may be to write your own.