Let \(\Gamma \) be a graph with vertex set \(V(\Gamma )\) . A subset C of \(V(\Gamma )\) is a perfect code of \(\Gamma \) if C is an independent set in \(\Gamma \) such that every vertex in \(V(\Gamma )\setminus C\) is adjacent to exactly one vertex in C. A subset T of \(V(\Gamma )\) is a total perfect code of \(\Gamma \) if every vertex of \(\Gamma \) is adjacent to exactly one vertex in T. Let G be a group with identity element e. The intersection graph of G, denoted by \(\Gamma (G)\) , is the graph whose vertex set consists of all nontrivial proper subgroups of G, and two distinct vertices H and K are adjacent if and only if \(H\cap K\ne \{e\}\) . In this paper, we establish necessary and sufficient conditions for the intersection graphs of finite abelian groups, generalized quaternion groups, and modular groups to have perfect codes and total perfect codes. We characterize dihedral groups and quasi-dihedral groups whose intersection graphs have perfect codes, and prove that the intersection graphs of dihedral groups and quasi-dihedral groups have no total perfect code. Furthermore, we explicitly provide some of the existing perfect codes and total perfect codes in the intersection graphs mentioned above.