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.
NOTE: In order to fix this problem, you will need to set the class on a transaction level. If you require a class for each line item, it will require customization to make the class column visible on the line items grid in Method.
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.
Click Save.