Intuitively, imagine examining your costs after replacing (say) $150$ of the devices. Around $30$ of them were replaced at a cost of $\$300$ each at the planned time of $12$ and the others were replaced at a cost of $\$350$ each at various random times between $0$ and $12,$ which must have averaged around $6.$ Overall, the total cost would be a little less than $150\times \$350$ and the total time those devices were running would have been around $30\times 12$ plus $(150-30)\times 6.$ That works out to a little under $50$ per unit time. Keep this in the back of your mind when reading the following rigorous solution.
Let the uniformly distributed time be $U.$ It is a random variable. Define $I$ to be the indicator that the planned replacement occurs: that is, $I=\mathcal{I}(U >= 12)$ equals $1$ when $U\ge 12$ and equals $0$ when $U\lt 12.$
$I = 1$ has a $(15-12)/15 = 3/15$ chance and $I = 0$ has a $12/15$ chance.
The cost of replacement can be expressed as $C = 350(1 - I) + 300 I.$
The time to replacement can be expressed as $T = 12I + U(1-I).$
Let's compute expectations.
$E[I] = \frac{12}{15}\times 0 + \frac{3}{15}\times 1 = \frac{3}{15}.$ This is the basic formula for expectation.
$E[C] = E[350(1 - I) + 300 I] = 350(1 - E[I]) + 300 E[I] = 350\times \frac{12}{15} + 300 \times \frac{3}{15}$ by linearity of expectation.
$E[T] = E[12I + U(1-I)] = 12E[I] + E[U(1-I)].$ The second expectation can be obtained as the integral $$E[U(1-I)] = \int_0^{15} u(1 - \mathcal{I}(u \ge 12))\,\frac{\mathrm d u}{15} = \frac{1}{15}\int_0^{12} u\,\mathrm du = \frac{1}{15}\frac{u^2}{2}\bigg|_0^12 = \frac{12}{15}\times 6.$$
The long run cost per unit time, $E[C]/E[T],$ is now readily calculated as
$$\frac{E[C]}{E[T]} = \frac{350\times \frac{12}{15} + 300 \times \frac{3}{15}}{12\times \frac{3}{15} + \frac{12}{15}\times 6} = 47\frac{2}{9}.$$
You should recognize your calculation in the numerator -- but that was only part of the correct answer.
This little R simulation of a million device replacements is informative for its simplicity and direct implementation of the problem:
u <- runif(1e6, 0, 15)
c. <- ifelse(u < 12, 350, 300)
t. <- ifelse(u < 12, u, 12)
mean(c.) / mean(t.)
When I ran it the difference between the output and the foregoing answer of $47\frac{2}{9}\approx 47.22$ was small enough to be attributed to the chance variation in the random results:
[1] 47.27247
This exposes an implicit assumption on my part. You might have plausibly interpreted "long run average cost per unit time" to be the expectation of the cost per unit time, $E[C/T].$ Here's the simulated value:
mean(c./t.)
[1] 312.3297
Clearly the answer is different -- but don't trust a mere simulation. In this interpretation the answer is infinite. We can underestimate this average by setting $C$ to the constant $\$300,$ giving an underestimate of $E[\$300/T],$ which is already infinite. See https://stats.stackexchange.com/a/299765/919 for an explanation.