You may also work the problem the other way around: build the numbers with this pattern.
FromDigits[{#[[1]], 5, #[[2]], 2, 1, #[[3]]}] & /@ Select[Tuples[Range[0, 9], 3], #[[1]] != 0 &]
This performs a bit faster.
Or, if you want it even faster:
Flatten@Table[FromDigits[{a, 5, b, 2, 1, c}], {a, 1, 9}, {b, 0, 9}, {c, 0, 9}]