Do used car dealers have to tell you a car has been totaled before you buy it?
Yes, they need to tell you this, assuming that they either knew it or reasonably should have known it i.e. that any car dealer, with typical car-dealer resources, in their position would have known. Otherwise, they may have committed fraud knowingly lied about a material, or important fact, upon which you reasonably relied, in order to induce you to enter into a transaction. Fraud can provide grounds to seek monetary compensation from the dealer E.g. the difference between the value it should have had, based on what they told you, and the value it does have or in some cases even void the contract return car, get money back. If they will not voluntarly provide compensation, your recourse would have been to sue them.
Note that if they can show that they themselves did not know and should not reasonably have known of the car's true history e.g. maybe they got it from another dealer, who lied them and/or falsified paperwork, they would not be liable being wrong is not fraud, only lying is.