How can the contract know the actual sales price? I.e. sure, it can see a transaction, but it can't see the second transaction with the rest of the sum, or the cash that changed hands at the same time.
My understanding is that the USD value attached to an NFT is just the equivalent of however much ETH is being traded. If some outside monetary platform is being used to exchange the item then the real price wouldn’t be known.
So basically the same way it's done with traditional meatspace paintings: you make a (legal) contract stipulating it, or you rely on people to do it because they think it's right.