There & away
Take bus lines 101 and 111 in the direction of "Hohenecken" to the bus stop "Hohenecken, Burg". The buses run every 30 minutes. Even faster is the regional train (RB 64 - direction Pirmasens) from Kaiserslautern main station to Hohenecken station. The regional train runs once an hour.
The route to the castle is signposted and easy to find from both the bus stop and the train station in Hohenecken.
The last train arrives at around 21:00. You have a little longer to get back by bus. The last bus on route 104 towards the city center leaves at around 22:00.
Google Maps - Hohenecken Castle