Topological terms on topological defects: a quantum Monte Carlo study