For example, each office in a company generally has one 課長 (kachou, section chief). When subordinate staff talk to or about him, they will call him 課長, instead of his name. This is generally true even if they meet for drinks after work, or some other relaxed setting. And a 校長先生 (kouchou sensei, school principal) will always be called 校長先生, long after he quits the job to tend to his flowers.
Foreigners working as English teachers in Japan experience this sometimes, when people who they’ve never taught refer to them directly as 先生 (sensei, teacher). Women who are obviously married (whether because of wedding ring, or just attitude) will often be called 奥さん (okusan, literally “wife”), almost the Japanese equivalent of “madam”, by shop staff and salesmen. Other people in a store will be called お客様 (okyakusama, customer) to their faces, as in 「お客様、こちらの窓口でお願いします。」 (“Okyakusama, kochira no madoguchi de onegai shimasu”, “Sir/Madam, I’ll help you at this window”).
It can often seem somewhat cold to a native English speaker to call a person by their job title rather than name, especially after you’ve become friends with them. But in Japan, it’s what’s expected of you. The good thing is, it means you don’t have to remember everybody’s name, as long as you can remember their title!