Meeting for the first time
When Japanese people meet for the first time, they say 'Hajime-mashite' which comes from the word hajimeru, to begin. They'll also give their name using the word 'desu' - 'Tanaka desu' - or 'to moshimasu' in a formal situation - 'Tanaka to moshimasu'. Usually they'll bow if the situation is formal or just give a nod of the head otherwise. Bowing is a bit complex - the degree of bowing depends on the formality of the situation and the relationship between the people. But foreigners are not expected to worry about this unless greeting the Emperor or on some such rare occasion.
Business people exchange meishi (business cards) and it is polite to use both hands when giving or receiving a meishi. You should read (or look as though you're reading!) the meishi and make some vague comment about the company or the address or whatever. It is not polite to immediately stuff the meishi in your trouser pocket or wallet.
Visiting someone's home
If you have been invited to someone's home, it is polite to bring a gift, usually an inexpensive food item, which should be wrapped. In Japanese, the visitor says 'Tsumaranai mono desu ga', meaning 'This is nothing much but...', similar to the English 'This is just a little something for you.' Every Japanese home has a genkan (hallway), where you take off your shoes and put on slippers provided by the host. Often, if you use the toilet, you'll have to change slippers again.
It is quite common for Japanese people to say 'Kondo asobi ni kite kudasai', or 'Please come around to my place sometime' to someone they barely know, but you should be careful. This is often said just out of politeness and there would be a lot of embarrassment if you actually turned up unannounced. It depends on the relationship, but generally this 'invitation' should be taken with a pinch of salt.
Visiting a Temple or Shrine
First of all, you may be wondering, "What's the difference?" A jinja is a Shinto shrine, while an o-tera is a Buddhist temple. One easy way to spot a shrine is the distinctive torii gate that marks the entrance (see photo below).
When visiting a temple or shrine as a tourist or casual visitor, there is no need to worry too much about dress. If you're visiting for a ceremony, a general rule of thumb is to follow whatever common sense rules apply to your own culture when it comes to public behavior and the dress code but also observe what others do around you and try to blend in the crowd. Japanese people are usually very forgiving of foreigners as they assume that we don't know anything about Japanese culture. So do not be shy to ask anyone for advice, even if it's with a gesture. Temple or shrine staff are generally happy to show you the proper way of doing things like the purification ritual, the offering of money or the prayer. If you want to come prepared, study the Japanese temple etiquette in advance and impress them with your knowledge.
This may sound like a joke but I've heard the mistake made more than once - o-tera is the word for a temple, whereas o-tearai is the polite word for a toilet!