This question is really “how do you make ANYTHING stay in the same place in an image?”
For that, the best thing to do is use the Motion Tracker in AE Pro. If you don’t have the Pro version, you can simply keyframe the motion, but it’s a lot more work. It doesn’t matter if you use Vector Paint or a mask, just ask long as it’s on it’s own layer this works fine.
To simplify the keyframing, you can use the binary search method. Set keyframes at the beginning and end. Then set a keyframe in the middle. Then set keyframes in the middle of each of the current keyframes. Then set keyframes in the middle of each of those keyframes. Repeat this process until the motion matches when you preview it. You may not have to set keyframes at every interval, so preview often, and add keyframes where it needs to be touched up.