。
I made a terrible mistake on the test.
Literal
I [topic-は] test [on-で] terrible mistake [object-を] did.
で here marks the location/context where an action happens ('on/in the test'), not the means or instrument. 間違いをする is the standard light-verb construction for 'to make a mistake' — Japanese prefers noun+する over a single verb for many actions.