a quick test with a piece of magnetic metal shows there are magnets at both ends of the charger cable connector and the Surface connector. I tested with a nail I had lying nearby, the nail itself is not magnetized. be careful not to contact electrical pins on either connector.
I'd confirm that your Surface and Charger Cable connectors have magnets at both ends in case somehow they came lose inside the Surface and moved away or never made it in during manufacture.
It might be possible to shape a piece of magnetic metal to the back of the cable connector which would potentially provide better hold. Do not wrap metal around the end of the connector completely as that would interfere with the contacts mating when it comes together. I'm thinking something no more than half the arc on the back edge of the cable connector might do the job. be sure to test it first before affixing it, perhaps thin double-stick tape would do. This is an untested concept idea, no guarantees. Proceed at your own risk.