Summary We estimate how the effect of antiretroviral treatment depends on the time from HIV-infection to initiation of treatment, using observational data. A major challenge in making inferences from such observational data arises from biases associated with the nonrandom assignment of treatment, for example bias induced by dependence of time of initiation on disease status. To address this concern, we develop a new class of Structural Nested Mean Models (SNMMs) to estimate the impact of time of initiation of treatment after infection on an outcome measured a fixed duration after initiation, compared to the effect of not initiating treatment. This leads to a SNMM that models the effect of multiple dosages of treatment on a time-dependent outcome, in contrast to most existing SNNMs, which focus on the effect of one dosage of treatment on an outcome measured at the end of the study. Our identifying assumption is that there are no unmeasured confounders. We illustrate our methods using the observational Acute Infection and Early Disease Research Program (AIEDRP) Core01 database on HIV. The current standard of care in HIV-infected patients is Highly Active Anti-Retroviral Treatment (HAART); however, the optimal time to start HAART has not yet been identified. The new class of SNNMs allows estimation of the dependence of the effect of 1 year of HAART on the time between estimated date of infection and treatment initiation, and on patient characteristics. Results of fitting this model imply that early use of HAART substantially improves immune reconstitution in the early and acute phase of HIV-infection.