"How can you assign an expense to a customer in an invoice. I have Essentials subscription"
To assign an expense to a customer in an invoice, you will need a Plus plan or Advanced plan. In Essentials plan (or Simple Start plan) such a feature in QBO is not available at this time. You can check out this helpful article to find out available features in different QBO plans.