No, you can't become infected in Left 4 Dead when you're not playing online.
The infection mechanic only comes into play in the appropriate multiplayer modes, so offline play keeps you safe from it.