Two potential explanations, both common with first gens Legacy's.
One, it's the fuel injectors just clacking away. They are noisy and sometimes get exessively.
Two, your HLA's need bleeding. Your engine has hydralic valve lash adjusters that will get air in them if your oil got too low at some point. Sometimes they just die. Either way it makes a heck of a racket. Often times replacing the oil will take of them but sometimes you have to take them out and manually 'refill' them. This is a simple process and you can leave the engine in the car. Just take off your valve covers, push on the various valves until you find the loose ones, push hard and if they're dead you'll know it. From there it's 8 bolts to pull off the rocker assembly and then the HLA's will pull out.
Have you taken a screwdriver to probe to find the noise? If it's coming from under the valve covers then I'd put my money on the HLA's.