2010 Subaru Legacy - Rear light is off and on

my rear tail light is not working sometimes it goes back on by self

Not sure if you made a statement or are asking a question…?

What have you done to resolve the issue so far?? Changed out the bulb with a new one?? Checked wiring, connecter etc??

Ask you shop to test for a correlation, light from bulb vs measured voltage at bulb’s wiring harness connection.

Try by checking the bulb. If it’s loose, damaged, or burned out, replace it and make sure it’s firmly in place. You can also use a multimeter or test light to test if there’s power reaching the socket when the taillight should be on. For a replacement, enter a VIN on https://www.subarupartsdeal.com/ and will narrow down the options for you.