it actually depends on the situation or relationship.

in person-person relationships in western countries it is usually earned. in eastern societies it is given and it is up to the recipient to keep it or lose it. i follow the later.

in the military it is demanded. those who fail to give it are court marshalled.

between parent and child it is first taught, then expected by the parent from the child. then as the child grows older it is both kept and earned. when the child becomes an adult then it could change as in person-person above.

between husband and wife (or lovers) it is given (or is the right word "offered"?), then kept or lost.

in the work place the word is not respect but courtesy. you may hate someone else's guts and that person happens to be your boss but you have no choice but to give courtesy. respect is a different matter. you can always answer back to your boss without being disrespectful.