Follows a verb of cognition (e.g., 見る, 思う, 聞く) to mean 'every time one does that action'. Often used in the pattern 〜につけて.
Every time I see his face, I remember the old days.
Used in the paired pattern 〜につけて〜につけて, often with contrasting adjectives or verbs, to mean 'whether A or B, in either case'. Common with words like 良い/悪い, 嬉しい/悲しい.
この曲を聞くにつけて、学生時代を思い出す。
Whenever I hear this song, I recall my school days.
Whether good or bad, we have no choice but to accept the result.
In joy or in sorrow, life goes on.
〜ごとに means 'each time' or 'every', often with a sense of repetition or intervals. 〜につけて is more about a trigger for a memory or feeling.
Derived from the verb 付ける (to attach) in its continuative form 付け, combined with the particle に. The expression grammaticalized into a conjunction-like phrase meaning 'on the occasion of' or 'whenever'.