If the class on a transaction gets blanked out when it syncs to QuickBooks online, then you will need to change how Classes are tracked within QuickBooks oniline.
Instead of setting the class on each line item, you will need to set the class on the transaction level.
Set Class on Transaction Level
Log in to QuickBooks Online.
Click the gear in the upper right, and go into Account and Settings.
On the left menu, click Advanced.
Under Categories, Track classes should be enabled. Click it to edit it.
Under Assign classes, change the dropdown to One to entire transaction.