It's been a while since I did this, but here's my recollection.
First, the notation using the lower-case letter p in front of something else means "the negative logarithm (base 10) of ....". So, pH means the negative log of the concentration (in units of molarity, or moles per litre) of Hydrogen ions; a value of pH = 4.0 means that the solution of acid contains 10^(-4) moles pf H+ ions per litre of solution. Similarly, pKa means "the negative log of the value of the acid's Dissociation Constant, Ka".
Now, Ascorbic acid is dibasic - that is, it has two possible hydrogen ions that can dissociate off of the molecule. The first one comes off easily, with pKa = 4.10. That means it will be dissociating readily in acidic environments that already have many H+ ions present. The second one will not come off until the environment has a huge deficiency of H+ ions - that is, it is basic - and its pKa is 11.6. You can ignore the second pKa thing. When you dissolve ascorbic acid in pure distilled water, effectively only the first acidic hydrogen will dissociate off, so work only with that value.
The Dissociation Constant, Ka, is the ratio of the concentrations of product species to source species in the dissociation equilibrium reaction. We will write the ascorbic acid as HA which can dissociate into ions H+ and A-. Note that, when one molecule of HA dissociates, it produces one ion each of H+ and A-. So, let us set up two algebraic variables:
Let x be the initial concentration of HA placed into the solution. Note that the units of concentration are moles per liter (Molarity). x is the amount of dry ascorbic acid powder (in moles) in one litre of pure water before its dissolves and dissociates.
Let y be the number of moles per litre of the original acid that dissociates.
Thus, at equilibrium after dissociation is stable, we have in solution (x-y) moles per liter of undissociated original ascorbic acid, and y moles per litre each of the H+ and A- ions. Then the equation for the Dissociation Constant is:
Ka = y*y/(x-y) = 10^(-4.10)
The second equation to set up comes from your target: the pH of the solution should come out to 4.0. That is, by definition of the term pH, the concentration of the H+ ions in the solution should be 10^(-4.0):
y = 10^(-4.0)
So, solve to get the value for x in moles per litre. Then calculate the Molecular Weight of Ascorbic Acid and convert moles per litre to grams per litre.