A knock or "ping" is caused by detonation which is premature combustion. This will occur from advanced timing or running too lean (too much air / not enough fuel.) In your case, I would suspect the latter. Most likely both issues are going to be from the same source. Probably fuel related. I know Firestone will perform a fuel system cleaning for $99 so that would be a great place to start. Even if the issue is elsewhere, a fuel system cleaning is a great service to perform on any vehicle over 30K miles. What was the issue with the exhaust manifolds? Were they cracked and leaking?
Have you ever replaced the mass air flow sensor? If it is acting erratic, it could have an internal fault giving false readings to the computer which would cause a running lean issue and possible knocking and misfires. Typically that part alone is around $150, but replacing it is easy. I would advise taking the vehicle to a shop for a diag. before just throwing a new mass air flow sensor at it. However, it is the one part above all others that controls the amount of fuel the engine gets. The PCM controls the fuel of course, but it uses the mass air flow to tell it how much air the engine is getting, if the reading is wrong, the computer doesn't know how much air is actually getting to the engine.