Does my government know in which country I am at when I travel?
I guess this is the type of question I should start with "a friend of mine wants to know..." but I was wondering if in general governments keep a record that gets updated each time you go through inmigration in another country in some sort of centralized database, or they have to check your passport stamps to check were you have been in between your departure and arrival.
I guess each country must have their own rules, but I am asking in a general sense.
Normally not through your passport since you may have more then one. But it's a lot easier to track you through your banking transactions. :)
They have found Bin Laden who doesn't even have a passport! sure they can find you if they wish...
Unless you're from a country that requires you to obtain an exit visa, there is no sharing of information as a general rule.
Even in cases where there are information sharing agreements, such as between the US and Canada, the US and Mexico, or in the Schengen area, the information that is shared is about people from outside the info-sharing nations, but not about their own citizens.
It may be possible for one country to ask for legal assistance to obtain information about a specific person, and who knows what information is shared by the secret services, of course, but on the visible side, countries do not know what their citizens do while away.
EDIT As pointed out by @MeNoTalk, the Advanced Passenger Information System (APIS), where airplane passenger data is transmitted to the destination country. Thus, your government may not know where you're headed, but they will know from where you return, if you come back by plane.
There are many ways if the government want to knows your locations, APIS is one of them, the data is held by the US government.