The reagent which is used to distinguish the substances should produce different results.
For clue draw structure of both.
Formic acid has −CHO group so it gives all tests of aldehyde group and OCOOH does not give. formic acid HCOOH+AgNO3+NH3→ silver mirror Ag+CO2+H2O CH3COOH+AgNO3+NH3→ No reaction acetic acid 2,4-dinitrophenyl hydrazine test is given by carbonyl compounds.