My '93 Ranger with 4.0L engine did something similar. I believe there was a tsb on it concerning an updated intake manifold gasket that Ford issued, covering all the 4.0L engines. I believe that the 4.0L was somewhat redisgned around '95 or '96, but the one in the Ranger looks very similar to the one in my ST, so I don't exaclty know what changed in them. The ST does have several more horsepower, so they had to of done something.
Anyway, I would get a rattle or tapping noise from the engine when it was under load. When I was researching this for the Ranger, I learned of the revised intake manifold gasket (I believe it was the one between the upper and lower plenums). A couple things I was told was to retorque all the manifold bolts per factory specs to make sure they are tight, and to pull the middle spark plug (can't remember which side) and if it had significantly more carbon buildup than the other plugs, this gasket was probably at fault. I never had the gasket replaced, just continued to drive it with the annoying noise. Eventually (unrelated I guess) I blew a head gasket and had to have the top end of the engine rebuilt. After they were finished (I assume they used the revised gasket), no more ticking/rattling.
I'm definitely not saying this is your problem, but it is something I would at least check. I don't have the torque specs/pattern for this engine, maybe someone else here does. I'd also check the exhaust manifold bolts to make sure they are tight. In my Mustang I had a loose header bolt and it made a ticking noise. Just a thought.