The first English meaning of gender was grammatical, applied to words, not people. Gender is prominent in languages like Latin or German, where every ordinary noun is masculine, neuter or feminine. This often baffles English-speakers who discover, for example, that the gender of Mädchen, the German word for girl, is neuter.
In the second half of the 20th century gender took on another meaning. Feminists used it to refer to the social and cultural expectations that are built upon sex differences. When people talk about “masculine” or “feminine” behaviour they are talking about gender, not sex. Hence gender studies, gender roles, gender bending and the rest.
Sometimes the right word is simply prescribed by prevailing usage. There is a gender pay gap in virtually every country and company (not a sex pay gap). Indeed sex sometimes clangs if it could be understood to mean sexual intercourse. But do not be afraid of the word when discussing biology.
With job titles, use those generic terms like police officer and firefighter that have become neutral and natural. It is standard in academia to speak of the chair of the history department. But elsewhere chairman and chairwoman are better. (Avoid chairpersons.) With other titles, actress and ballerina are no more demeaning than baroness or queen. Use another title only if someone is known to prefer it.