With my (paid) extension Pins & Boxes, you could create a pin at the location of the text where the image should be (like the bottom center or right edge, for example) and then simply parent the background image to this pin. When the text changes, the pin updates its position and the parented image follows it. Note that when you create it with Pins & Boxes, the clients who use your template DON'T need to have Pins & Boxes installed. So it is no problem to use the extensions to create mogrts which work everywhere.
Without Pins & Boxes, you could write your own expressions which measure the size of the text. Google for the sourceRectAtTime() expression if you want to try that - put this requires some level of programming experience.
You can rely on the sourceRectAtTime() expression method to define the top, left, height, and width of a text layer at any point in the animation. Then those values can be used to position your graphic. By far the easiest solution would be to pay for a solution as Mathias suggested. You could also dig through the tutorials on soureRectAtTime(), but most of them are pretty lousy. If you have a few days I might get my new tutorial series on text animation published. It will show you everything you need to do what you are describing.