To answer your initial questions, you will only earn the miles as if it were a nonstop from SFO-BKK. Since it is the same flight number (NW27), it is a "direct" flight and you will not be credited with a connection or the connecting miles. Coming from TPA, you should consider other options:
You have 10 basic options (without getting into MR routings) assuming you start your trip in TPA, assuming you don't go through MEM, and assuming you don't do any hub backtracking (i.e. xxx-MSP-DTW-xxx). These 10 options are:
#1 TPA-DTW-NRT-BKK (10273 miles)
#2 TPA-MSP-NRT-BKK (10150 miles)
#3 TPA-DTW-SFO-BKK (10999 miles)
#4 TPA-MSP-SFO-BKK (10833 miles)
#5 TPA-DTW-SEA-NRT-BKK (10571 miles)
#6 TPA-DTW-LAX-NRT-BKK (11305 miles)
#7 TPA-DTW-PDX-NRT-BKK (10651 miles)
#8 TPA-MSP-SEA-NRT-BKK (10368 miles)
#9 TPA-MSP-LAX-NRT-BKK (11187 miles)
#10 TPA-MSP-PDX-NRT-BKK (10448 miles)
Of these 10 options, #6 earns the most miles followed very closely (~100 miles less) by #9. #2, #1, #10, #5 should be avoided as they are the routings that earn the least, with #2 being the least.
However, all told, the difference between the worst and best is only about 1150 miles (2300 R/T). If you're really interested in earning more miles, you should look at the routings and see what cities (other than the west coast gateways) you can connect to from DTW, MSP, and MEM.
It should be noted, however, that as a personal preference, you may prefer to fly the new 332 as opposed to the older 742. The 332 flies from SEA, PDX, and SFO, while the older 742 flies from LAX. If you want to avoid the older 742 across the pond, then your best bet, ironically, becomes #3, which is the direct NW27 flight. Food for thought...
All calculations provided by Fare Metrics