A hack with section-subsection redefining:
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{subsection}
\global\let\oldsection\section
\global\let\oldthesubsection\thesubsection
\xdef\oldeqnum{0}
\makeatletter
\def\section{%
\xdef\mdepth{1}
\gdef\thesubsection{\thesection}
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\setcounter{equation}{\oldeqnum}
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}
\def\@StarredWith[#1]#2{%
\oldsection*{#2}%
}
\def\@StarredWithout#1{
\oldsection*{#1}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldsection[#1]{#2}%
}
\def\@nonStarredWithout#1{%
\oldsection{#1}%
}
\let\oldsubsection\subsection
\def\subsection{%
\ifnum\mdepth=1
\xdef\oldeqnum{\the\value{equation}}\fi
\xdef\mdepth{2}
\gdef\thesubsection{\oldthesubsection}
\@ifstar{\@Starreds}{\@nonStarreds}%
}
\def\@Starreds{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWiths}%
{\@StarredWithouts}%
}
\def\@StarredWiths[#1]#2{%
\oldsubsection*{#2}%
}
\def\@StarredWithouts#1{
\oldsubsection*{#1}%
}
\def\@nonStarreds{%
\@ifnextchar[%
{\@nonStarredWiths}%
{\@nonStarredWithouts}%
}
\def\@nonStarredWiths[#1]#2{%
\oldsubsection[#1]{#2}%
}
\def\@nonStarredWithouts#1{%
\oldsubsection{#1}%
}
\makeatother
\begin{document}
\section{No subsection here}
\begin{equation}
f(x)=0
\end{equation}
\begin{equation}
g(x)=0
\end{equation}
\section{With subsection here after first equation}
\begin{equation}
f(x)=0
\end{equation}
\subsection{Test subsection 1}
\begin{equation}
g(x)=0
\end{equation}
\section{With subsection here}
\begin{equation}
F(x)=0
\end{equation}
\subsection{Test subsection 2}
\begin{equation}
f(x)=0
\end{equation}
\begin{equation}
g(x)=0
\end{equation}
\subsection{Test subsection 3}
\begin{equation}
F(x)=0
\end{equation}
\begin{equation}
f(x)=0
\end{equation}
\begin{equation}
g(x)=0
\end{equation}
\begin{equation}
h(x)=0
\end{equation}
\section*{Continue numbering as section 3}
\begin{equation}
f(x)=0
\end{equation}
\begin{equation}
g(x)=0
\end{equation}
\end{document}
Output:

As you can see you can use combinations and can get back to previous section numbering by a starred section
Used this answer of mine:
https://tex.stackexchange.com/a/380116/120578
\arabic{equation}doesn't print a leading0. – Werner Sep 19 '19 at 16:27\numberwithinbut this is independent of what you stated. It works now but I'm still trying to figure out what went wrong when I was getting that leading 0. – MauOlivares Sep 19 '19 at 17:03