A Paris court ruled that his death was an industrial accident and that the family was entitled to compensation.
The firm had argued the man was not carrying out professional duties when he joined a guest in her hotel room.
But under French law an employer is responsible for any accident occurring during a business trip, judges said.
The man, named as Xavier X, was working as an engineer for TSO, a railway services company based near Paris.
He died at a hotel during a trip to central France in 2013, as a result of what the employer called "an extramarital relationship with a perfect stranger".
The company challenged a decision by the state health insurance provider to regard the death as a workplace accident.
The provider defended its position by insisting that sexual activity was normal, "like taking a shower or a meal".
In its ruling, the Paris appeals court upheld this view.
An employee on a business trip is entitled to social protection "over the whole time of his mission" and regardless of the circumstances, it said.