Here "heart" is a metonym for a person's mind or inner being. Alternate translation: "thinks to himself" (See: [[rc://en/ta/man/translate/figs-metonymy]])
The words that are translated here as "male and female servants" are normally translated as "boys" and "girls." They may indicate that the servants were young or that they were dear to their master.