An avatar is a photographic representation of a user (usually a portrait). The avatar can stand alone, but is often associated with a username.
Use the avatar when it is necessary to visually identify a user, which could be in a login area in the app header, or in a chat post, or in a work group restricted to certain users, for example.
It helps to personify users and make them more human for other app users (a face is much easier to recognize by the human brain). Moreover, contextual information may be displayed with a click on the avatar (profile, account configuration, replacing the photo, etc.).
In case no picture has been uploaded yet or no image is available (for a guest user, for example), in these cases, an image placeholder is used by default.