As you would be flying on 220 LH or LX 724 Ticket stock, NOT UA 016 Ticket stock, Miles are earned according to DISTANCE. UA mile per $$$ only applies $$$ Spent on its own ticket stock, and on say a 220 (LH ticket) UA SFO-SYD as a 1K earnt me 20397 United MileagePlus Miles booked in D Class Business and the "free" EWR-SFO or other such domestic US sector also earns per miles flown as it is still on LH ticket stock eg I earnt 7689 Miles EWR-SFO on UA as part of fare in D Class with a Bonus for 1K
See
https://www.united.com/ual/en/us/fly/mileageplus/earn-miles/airline-partners/lufthansa.html and checkout "Ticket # does not start with 016)
Qantas books into I class in Business Domestic as QF are reticent to release D Class, and International to connect to LH/LX/NH/SQ *A etc should book into D class Qantas, but again good luck as QF are reticent also for international sectors
Booking class you pay for, say in Business, depends upon whether you want to use upgrade instruments. That depends upon your individual circumstances and what upgrade instruments you have available It is a complicated fare and I have found over the several decades I have used it yearly that travel agents may find it too complicated and therefore not fully inform you as to the booking classes, change fees, refund fees etc For example you can book into cheapest Business P class but then you need to use a lot more LH or UA miles
As I said previously, these are excellent fares, and I have been using them for decades, in fact the earlier fares in the early 2000's allow purchase of 4 LH/LX/OS flight coupons for AUD$100 each (plus taxes) in Economy, then they swapped to a Star Alliance Airpass, where Airpass baggage allowance must match intercontinental ticket it is purchased against
As to the Finnair AY fare, I can not comment