The easiest rules to remember are:
In signature lines at the end of a letter or email, the job title would be capitalized, like:
Mary Contrary, President
If a job title is not preceded or followed by a person’s name, it may still be capitalized, if it is used as a name. For example: "I saw the Prime Minister today." In this case, it is being used as name and not a general kind of job, as in "We have had eleven prime ministers in this century."
To summarize the capitalization of job titles, you capitalize the job title when it comes immediately before the name or immediately after the name. It is not capitalized if it comes after the name if there is a “the” before it.
Here are some examples of these rules in sentences:
Another rule of capitalization of job titles concerns abbreviations. Doctor Seuss would be Dr. Seuss and General Grant would be Gen. Grant. So the rule could be: capitalize job titles or abbreviations that come immediately before or after a person’s name.