First of all you need to get the invites. When you bump into fellow travelers always express your lifelong heartfelt dream to visit their country. Mention your vague plans to visit their country and even if you can’t get their address at least offer to exchange emails.
The important thing is to get as many contacts as you can so that you can build up a good portfolio of potential places to stay. Send emails reminiscing fondly of your meeting with that person and keep the connection strong – you never know when you might find yourself in their corner of the world.
If you’re starting from scratch then there are some excellent resources on the internet for the traveller in need of hospitality. Just be aware that you might need to send out plenty of requests to get a response and you’d better have an attractive profile with photos of you looking safe-yet-interesting. A few references wouldn’t hurt and when you write requests show that you’ve read their profile – if you didn’t bother to find out their name why should they open their home to you?
http://www.couchsurfing.org is the most popular and active site but they’ve sold out to clueless corporates who are slowly but steadily gutting the site of all it’s original spirit. Still a very useful resource to find a bed though.
http://www.bewelcome.org is where everyone is running to from Couchsurfing in search of that original good feeling between travellers. The functionality is currently pretty basic but changes are reportedly in the works.
http://www.hospitalityclub.org – was the original hospitality exchange site but seems pretty dead in the water these days.