My boss told me I’ve been overpaid by $7K, and I can either pay it all back or work without pay — is that even legal?

My boss told me I’ve been overpaid by $7K, and I can either pay it all back or work without pay — is that even legal?