Often considered the most difficult rule of French grammar, this rule of agreement of the past participle with reflexive verbs nevertheless always follows the same logic. The past participle agrees with the direct object (never the indirect object) if it is placed before the verb. In the first sentence “se” is a direct object, which is why agreement is necessary. However, in the second sentence, “se” is an indirect object. Therefore, no agreement is needed.
Here are a few more examples to help you master the rule.