Duty is usually used to mean something that we have to do because of society's or the family's rules. Military duty would be included in society.
"It is your duty as a citizen to report a crime."
Obligation is less formal (many times) and something that is given to us by ourselves or by circumstances.
"He felt an obligation to help Ted because of Ted's support in the past."