This is not a direct answer, but also too long for a comment.
You may be interested in Berge's Maximum Theorem, which I quote below from Aliprantis and Border (2006) (Theorem 17.31). A correspondence $F\colon X \twoheadrightarrow Y$ is a set-valued function that maps each $x\in X$ into a subset $Y$. I will define continuity for correspondences after the statement of the theorem.
Theorem (Berge). Let $\varphi\colon X\twoheadrightarrow Y$ be a continuous correspondence between topological spaces with nonempty
compact values, and suppose $f\colon X\times Y\to\mathbb R$ is
continuous. Define the "value function" $m\colon X \to \mathbb R$ by
$$ m(x) = \max_{y\in\varphi(x)} f(x,y), $$ and the correpsondence of
maximisers by $$ \mu(x) = \{ y \in \varphi(x) : f(x,y) = m(x) \}. $$
Then,
- the value function is continuous;
- the argmax correspondence $\mu$ is upper hemicontinuous and has nonempty compact values.
The statement of this theorem in Aliprantis and Border is actually slightly more general than this (they require only continuity of $f$ on the graph of $\varphi$), but I have taken liberties for simplicity.
A neighbourhood of a set $A$ is any set $B$ containing an open set $V$ such that $A \subset V \subset B$.
We say that a correspondence $\varphi\colon X \twoheadrightarrow Y$ is upper hemicontinuous (uhc) if for every $x \in X$, and every neighbourhood $U$ of $\varphi (x)$, there is a neighbourhood $V$ of $x$ such that $z \in V$ implies that $\varphi (z) \subset U$.
A correspondence $\varphi\colon X \twoheadrightarrow Y$ is lower hemicontinuous (lhc) if for every $x \in X$ and every open set $U$ such that $\varphi (x) \cap U \neq \emptyset$, there is a neighbourhood $V$ of $x$ such that $\varphi (z) \cap U \neq \emptyset$ whenever $z \in V$.
A correspondence is continuous if it is both uhc and lhc.
One might wonder whether it is possible to find a continuous function $g$ such that $g(x) \in \mu(x)$ for each $x$, so that $g$ is a continuous selection from $\mu$. However, as we can see above, we can only guarantee that $\mu$ is uhc, and continuous selection theorems I am familiar with usually require that the correspondence we are selecting from be lhc.
However, since we know that $\mu$ is uhc, we also know that $\mu$ is continuous when viewed as a function from $X$ into $Y$ whenever we can guarantee that $\mu(x)$ is a singleton for each $x$. A sufficient condition for this is for $f$ to be strictly concave in $y$ for each $x$, with $\varphi$ being convex-valued (that is, $\varphi (x)$ is a convex set for each $x$).
To see this, suppose that $y,y^\prime \in \mu(x)$, with $y\neq y^\prime$. Then, from strict concavity of $f(\cdot ,x)$ and the fact that $\varphi(x)$ is convex, we have that, for $\alpha \in (0,1)$, $$ f(x, \alpha y + (1-\alpha) y^\prime) > \alpha f(x,y) + (1-\alpha) f(x,y^\prime) = m(x)$$ and $\alpha y + (1-\alpha) y^\prime \in \varphi (x)$, a contradiction. This means that $\mu$ is uhc and singleton-valued, and is therefore continuous when viewed as a function.