Do IgM and IgG differ for different infections?
IgM (Immunoglobulin M) is the first antibody to appear in response to an antigen. It can be produced by the fetus and cannot be crossed by the placenta. 

Typically one might test IgM to diagnose hereditary and acquired IgM immunodeficiencies or diagnose Waldenstrom macroglobulinemia. It can serve as the earliest Ig serologic diagnosis of infectious disease.

Lab tests for IgM may be increased in liver disease, chronic infection, hyper IgM syndrome, and secondary to nephritic syndrome; Waldenstrom macroglobulinemia, lymphoma, CLL, multiple myeloma (rare), Schnitzler syndrome, cold IgM antibody agglutin, and MGUS. 

Lab tests for IgM may be decreased in protein-losing syndromes, non-IgM myeloma, and infancy/early childhood.

IgG (Immunoglobulin G) activates complement and fights infection. IgG represents 70-80% of the total serum immunoglobulins in normal adults. It exists in four subclasses (IgG1, IgG2, IgG3, and IgG4). IgG1 predominates as 65% of the total IgG. IgG of maternal origin provides passive immunity to the neonate. It is transported across the placenta. 

Typically one might test IgG to diagnose IgG myeloma, diagnose hereditary and acquired IgG immunodeficiencies, and provide a serologic diagnosis of infectious diseases and immunity.

Lab tests for IgG may be increased in multiple myeloma, solitary plasmacytoma, MGUS, lymphoma, CLL, sarcoidosis, cirrhosis, autoimmune diseases, parasitic diseases, chronic infection, and intrauterine contraceptive diseases.

Lab tests for IgG may be decreased in protein-losing syndromes, pregnancy, non-IgG myeloma, Waldenstrom macroglobulinemia, primary immunodeficiency states, and agammaglobulinemia (if combined with other immunoglobulin decreases).

Sources:
https://5minuteconsult.com/collectioncontent/2-152356/lab-tests/immunoglobulin-m-igm
https://5minuteconsult.com/collectioncontent/2-152354/lab-tests/immunoglobulin-g-igg