I don't normallly bother to answer questions on this board because most of them can be answered by opening a book or doing a search. But yours i found interesting.
You probably hav a junction box in the wall that was installed poorly.
When the electicity is on, there is a instrument that electronically follows the wires in the walls. where it stops- hit the wall an see if you lose current.
When the electicity is off. Hook up a tone generator and buzz it out looking for the split.
Only fix is to punch a hole in the drywall and fix the junction.