addressing the effect of the independent variable on the dependent variable for 2 different types of individuals I am estimating the effect of a continous treatment X (that goes from 0 to 1) on a dependent variable y (data is taken through an experiment).
I have around 250 Individuals in my dataset that can be divided in two, depending on another variable (50 in group 1 and 200 in group). I want to test if the effect of X on Y varies depending on the group to which the individual belongs
so i developed this model

where D is a dummy variable stating if individual i belongs to group 1 and group 2. So basically multiplying x for D I can obtain estimates of of the coefficient of x separately.
Finally I performed an F-test to show that B1 and B2 are different from one another. Does it sound right to you?
Alternatively, I could run the equation separately for the two groups but I obtain very similar results and the two groups are quite unbalanced..
 A: Let $D_i=1$ if individual $i$ is in group 1, = 0 if in group 2. In can fit the model
$$Y_i = \beta_0 + \beta_1D_i +\beta_2X_i + \beta_3X_iD_i + \beta_4 Z_i +\epsilon$$
where $Z_i=$ opinion.
By this model, you fit two lines for group 1 and 2. For group 1,
$$E(Y)= \beta_0 + \beta_2X_i +\beta_4 Z_i$$ For group 2 you have,
$$E(Y) = (\beta_0 + \beta_1) + (\beta_2 + \beta_3)X_i + \beta_4 Z_i $$
So  if the effect of X on Y varies depending on the group to which the individual belongs is determined by if $\beta_3 = 0$. So testing the null hypothesis $H_0: \beta_3=0$ to achieve your goal.
Note 1: $\beta_1D_i$ should be included in the model, given $\beta_3D_iX_i$ exist in the model, even test shows that $\beta_1 = 0$ is acceptable (high p value).
Note 2: "run the equation separately for the two groups" is bad idea, because it is hard to test if two lines have the same slope.
Note 3:if "the two groups are quite unbalanced" means the numbers of individuals have big difference (50 vs 150) in two groups, then you do not need to worry about it. We concern the number of individuals in the smaller group. If one group just have 5 individuals, the reliability of fitted model is very low. In your situation, 50 individuals should be OK.
A: Your current procedure seems right to me, but you could make it even simpler by considering:
$$Y = \gamma_1 X + \gamma_2 X * D_2 + (...) $$
As you only have 2 groups, $\gamma_2$ will be significantly positive only if the specific effect of X on Y is higher for group 2.
Ps: Note that you might also be interested to have in the equation group fixed-effect $T_1$ ?
