If the endcaps installed are correct for the frame and wheel interchangeability isn't working, there's nothing about the fact that this is a Di2 bike of any generation that makes finding the solution any different. When things are right, there is no need for adjustment when switching back and forth from the trainer.
The most common source of confusion whenever 10-speed is involved is when a Shimano road 10 cassette that came with a 1mm spacer has had it left out when installed on a freehub body where it is needed to locate the cassette properly, which is all of them except for the circa-2004 full aluminum tall-spline Dura Ace models. If the cassette you're using on the trainer came with this spacer, you need it on in addition to the 1.85mm one that came with the trainer for 10-speed compatibility.
If that spacer was left out on either of the cassettes in question, this problem can be the result. You can check for problems of this sort by observing with a caliper or small ruler whether the small cog tooth centerline is landing the same distance away from the inner dropout face on both cassettes.
There are some situations where something about the hub is dimensioned such that those distances aren't exactly the same even when the space configuration is right. Usually this either certain weird hubs or someone doing something unorthodox with the freehub or axle hardware. In these cases, it can be necessary to use cassette spacers to make the interchange work, but this is the exception to the norm.
If that's not the problem, the next thing to look at is hanger alignment and/or cable friction causing the tolerances needed for things to work to be overly tight.