Our sentence is:
Compro la gasolina en la estación de servicio
So a direct object pronoun replaces a direct object, that is a noun that directly receives the action of a verb in a sentence. Moreover, direct object pronouns in Spanish agree in number and gender with the nouns they replace.
In our sentence, La gasolina is the direct object because it receives the action of the verb. Since La gasolina stands for the third person singular (feminine form), we need to use the direct object pronoun that matches this person, which is la. Therefore, the new sentence is:
La compro en la estación de servicio