The paper was written and submitted when I was in Institution A.
After (many) years, the paper is accepted when I am in Institution B.

Which address shall I put on the paper?

The current address (Institution B) will soon expire since I will have to move somewhere else. So when the paper will be finally published online / on paper, neither A or B is valid address.