In Ownership of Dwight
In the season 6 episode "The Lover," Dwight is shown tinkering with the mallard late in the night at his desk, using black tape to secure a listening device to the bottom of the mallard. In the morning, Dwight introduces the mallard to Jim, along with a pen that Jim supposedly left on his desk, as a gift of "con-quack-ulations" for earning the promotion Dwight coveted. Jim accepts the mallard and places it on his desk as Dwight walks away.
In Ownership of Jim
Jim starts to play opera at an alarmingly high volume, and Dwight's earbuds let out the music to the whole office. Under the pretense that he was thinking of getting the music for Dwight's birthday, Jim stretches the conversation longer, and when Dwight questions Andy about this meetup, Andy does not say, making Dwight suspicious.
In Ownership of Kelly
Dwight soon becomes suspicious and irritated when hearing Kelly and Ryan gab about their love plans, and storms over to find that Kelly has affectionately named the mallard Professor Damon D. Duck, and that she refuses to give him up.
Dwight is eventually able to use money to purchase Professor Damon D. Duck back, but this time, Jim is confrontational about the mallard and Dwight admits his wrongdoing.
After everyone leaves the office, Dwight takes the pen that Jim supposedly left on his desk and reveals that it was a recording pen. He proceeds to listen to many hours of boring recordings.