As stackoverflow.com has logo with it's title, how it can be done for any usual site? Which code is needed for this?
Are you referring to the favicon?
Upload a 16x16px ico to your site, and link it in your
<link rel="shortcut icon" href="/favicon.ico" />
There are a multitude of sites that help you convert images into .ico format too. This is just the first one I saw on Google. http://www.favicon.cc/