I have a flight from Toronto (YYZ) to Karachi (KHI) on Emirates. EK4670 operated by WestJet will take me to Boston first, and after 4 hours layover, EK 238 will take me to Dubai and onwards to Karachi. After reaching Boston, USA, do I have to go through customs and collect my bags and recheck them again? Or will my bags go directly to the final destination once they are checked from Toronto?
Presuming your entire itinerary (YYZ-BOS-DXB-KHI) has been booked on a single ticket, you should not need to reclaim your bags in Boston. When checking in at Toronto, your bags should be checked through to KHI; check the tag and your claim receipt to make sure this is the case.
YYZ is a pre-clearance airport, so you will go through the formalities of entering the United States in Toronto before departure, rather than after your arrival at BOS. Therefore, unlike travelers arriving at BOS from a non-pre-clearance airport, you will not normally need to reclaim your bags to go through customs screening, and should not need to reclaim them until you arrive at KHI.
You will still need to get yourself from Terminal A, where your WestJet flight should arrive, to Terminal E, where your Emirates flight should depart, and this does involve exiting the secure area and taking one of the free interterminal shuttle buses.