How to determine what directly imaged objects are? A directly-imaged object found close to a certain star could be another star in the background or a  companion planet? 

How would one possibly discern between the two?
Also would we know it works?
Simple really. You observe again and see if the pair are moving together. If the star plus "planet" are quite widely separated (e.g. tens of au or more), then you would expect negligible orbital motion in the course of say a year and their relative position should remain quite constant.

On the other hand, if the "planet" is a much more distant star then it is quite likely to have a very different proper motion on the sky to the foreground star and so they will show an appreciable difference in their relative positions second time around.

More than two observations might be needed to be sure. The bigger the proper motion of the foreground star, the more decisive the test.