While both can be used to counter the negative effects of an imbalanced dataset, you will see different results, as the strategies of over-/undersampling and loss weighting are independent to each other.