I am an Australian citizen visiting the USA using the Visa Waiver Program next week. I have flights booked Houston → Mexico City → Havana → Miami.
As far as I understand I will be fine getting into Cuba after buying a tourist card in Mexico City, however I'm concerned about my return to the USA into Miami - I doubt the Mexican airline will supply an Office of Foreign Assets Control at any point going in, and arriving in Miami without one (and a Cuban stamp in my passport) may cause concerns in Immigration.
Ideally I will be able to use an ePassport gate where I do not encounter an actual human Immigration Officer, however this isn't guaranteed.