You shouldn't restrict that question to Tb and U.
In lanthanides, Pr, Nd, Pm, Sm, Eu, Tb, Dy, Ho, Er, Tm, Yb have [Xe]4f
n6s
2 type configuration. Meanwhile, La, Ce, Gd, Lu have [Xe]4f
n5d
16s
2 type configuration.
In actinides, Pu, Am, Bk, Cf, Es, Fm, Md, No have [Rn]5f
n7s
2 type configuration. Meanwhile, Ac, Th, Pa, U, Np, Cm, Lr have [Rn]5f
n6d
m7s
2 type configuration.
I am not sure if you can consider these two series to have different d-orbital configuration solely as "lanthanide vs actinide" problem.
As
@DrDu mentioned, there are many factors that contribute to the ultimate electron configuration of these elements, so it's hard to say what is exactly the reason for this trend. As a matter of fact, one reason don't explain all of the trends. I am going to answer the question with the best I know, and what I've heard in conferences. I'm not a professional in electronic energies of neutral lanthanides and actinides, so please take it with a grain of salt.
First, you should treat f
0, f
7, and f
14 elements as exceptions. These have none, half, or fully occupied f-orbitals so they are relatively stable with that f-electron configuration. It is therefore expected that the remaining electrons will occupy other orbitals, namely d- and s-orbitals. This is why La, Gd, Lu, Ac, Cm, and Lr have d-orbitals occupied.
Second, lanthanides and actinides have different f- and d- orbital energy splitting. Lanthanides have larger energy splitting between f- and d-orbitals due to 4f-orbitals being relatively closer to the nucleus than 5d-orbitals (which is what
@DrDu mentioned about nuclear charge screening effect, which changes the effective nuclear charge that orbitals feels). This causes actinides to be more susceptible to having d-orbitals occupied than lanthanides.
Third, you should treat lighter and heavier elements of the series differently. Relativistic effects cause larger energy splitting of f- and d-orbitals with larger atomic number. This means that lighter elements of series tend to have smaller f- and d-orbital splitting, hence the Ce in lanthanides and Th, Pa, U, Np in actinides, both being the lighter element of the series, having occupied d-orbitals. You can see that Th, the lightest actinide other than Ac (exception mentioned above) contains not one but
two 6d electrons! You can also see that none of the heavier lanthanides or actinides have any electrons in the d-orbitals.