Superconducting materials with a nontrivial band structure are potential candidates for topological superconductivity. Here, by combining muon-spin rotation and relaxation ($mu$SR) methods with theoretical calculations, we investigate the superconducting and topological properties of the rock-salt-type compounds NbC and TaC (with$T_c$ = 11.5 and 10.3 K, respectively). At a macroscopic level, the magnetization and heat-capacity measurements under applied magnetic field provide an upper critical field of 1.93 and 0.65 T for NbC and TaC, respectively. The low-temperature superfluid density, determined by transverse-field $mu$SR and electronic specific-heat data, suggest a fully-gapped superconducting state in both NbC and TaC, with a zero-temperature gap $Delta_0 = 1.90$ and 1.45 meV, and a magnetic penetration depth $lambda_0$ = 141 and 77 nm, respectively. Band-structure calculations suggest that the density of states at the Fermi level is dominated by the Nb $4d$- (or Ta $5d$-) orbitals, which are strongly hybridized with the C $p$-orbitals to produce large cylinder-like Fermi surfaces, similar to those of high-$T_c$ iron-based superconductors. Without considering the spin-orbit coupling (SOC) effect, the first Brillouin zone contains three closed node lines in the bulk band structure, protected by time-reversal and space-inversion symmetry. When considering SOC, its effects in the NbC case appear rather modest. Therefore, the node lines may be preserved in NbC, hence proposing it as a potential topological superconductor.