toggle Object Mode  Pose Mode by script code
Probably the easiest way for you to toggle between Object Mode and Pose Mode is to simply call bpy.ops.object.posemode_toggle() again. If you're in Object Mode, that will switch you to Pose Mode. If you're in Pose Mode, then you'll go to Object Mode. Here is a link to the Blender 2.83 API, though unfortunately the description is sparse.

Here's a quick script you can run to test, where here I've also created an armature and showed one way to move it via keyframing (since it seems like you were interested in doing that).

import bpy
from mathutils import Vector

# Make armature
bpy.ops.object.armature_add(enter_editmode=False, location=(0, 0, 0))
arm = bpy.context.object

# Enter pose mode.
bpy.ops.object.posemode_toggle()

# Assign keyframes to the armature.
arm.pose.bones['Bone'].keyframe_insert('location', frame=0)
arm.pose.bones["Bone"].location += Vector((0,2,0))
arm.pose.bones['Bone'].keyframe_insert('location', frame=20)
arm.pose.bones["Bone"].location += Vector((0,0,2))
arm.pose.bones['Bone'].keyframe_insert('location', frame=40)

# Return to object mode.
bpy.ops.object.posemode_toggle()


If the code above is in a file test.py, then run blender -P test.py.

If the last line is commented out, you will see this when Blender opens in Pose Mode:



If you leave it un-commented in the code, then you will see this when Blender opens in Object Mode: